设置NSWindow为重点 [英] set NSWindow focused

查看:227
本文介绍了设置NSWindow为重点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序有一个窗口和一个面板连接到该窗口.

I have an app winth one window and one panel, attached to this window.

步骤:

  1. 停用我的应用程序(应用程序已打开,但没有焦点)
  2. 单击面板上的按钮(面板现在处于聚焦状态,但主窗口未聚焦)

如何从面板上将焦点设置到主窗口(父窗口)?

How to set focus to the main window (parent window) from the panel?

推荐答案

不清楚焦点是什么意思,以及您所说的主窗口是否是Cocoa中定义的主窗口.假设它是可可的主窗口,并且焦点与键状态相同,

It is not clear what you mean by focus, and whether what you call main window is a main window as defined in Cocoa. Assuming it is a Cocoa main window and focus is the same as key status,

[[NSApp mainWindow] makeKeyWindow];

[[NSApp mainWindow] makeKeyAndOrderFront:self];

如果它不是可可主窗口,则需要对其进行引用并将其发送给-makeKeyWindow-makeKeyAndOrderFront:.

If it is not a Cocoa main window, you need to have a reference to it and send it -makeKeyWindow or -makeKeyAndOrderFront:.

这篇关于设置NSWindow为重点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆