禁用窗口单击时的应用程序激活
在我的 Cocoa/Objective-C 应用程序中,我有一个“始终位于顶部”浮动的实用程序面板,即使我的应用程序未处于活动状态也可以访问。我试图禁用“当用户单击该面板时切换到我的应用程序”。
我想要实现的行为类似于 OSX 的键盘查看器(这也是一个从不激活面板),以便在单击我的应用程序面板后某些其他应用程序保持活动状态。即,当使用键盘查看器输入地址时,Safari 保持活动状态。即使是第三方屏幕键盘也具有此功能(例如 CORALLO Software 中的键盘),这意味着此行为并非仅为系统保留。
我正在摆弄 NSApplicationActivationPolicy,但没有得到积极的结果。我应该往哪个方向走?
In my Cocoa/Objective-C application I have a utility panel floating "always on top" to be accessible even when my application is not active. I am trying to disable the "switching to my application when a user clicks on that panel".
The behaviour I would like to achieve is similar to OSX's Keyboard Viewer, (which is also a never activating panel), so that some other application remained active after clicking on my app's panel. i.e. Safari stays active when typing an address using Keyboard Viewer. Even third-party onscreen keyboards have this functionality (for example the one from CORALLO Software), which means this behavior is not reserved system-only.
I was messing around with NSApplicationActivationPolicy
, but without positive results. In which direction should I go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该查看
NSWindow
上的canBecomeKeyWindow
和canBecomeMainWindow
方法。听起来您希望您的窗口保持键状态,但不能成为主窗口。以下是一些可以帮助您的资源:NSWindow 类参考
- 跳转到
canBecomeKeyWindow
和canBecomeMainWindow
部分You should take a look at the
canBecomeKeyWindow
andcanBecomeMainWindow
methods onNSWindow
. It sounds like you want your window to maintain key status while not being able to be the main window. Here are some resources to help you:NSWindow
class reference - Jump to the sections oncanBecomeKeyWindow
andcanBecomeMainWindow