带有自定义视图的自定义 NSStatusItem - 使用 NSWindow、NSView、自定义 NSMenuItem?
我正在尝试创建一个 LSUIElement 应用程序,其行为类似于 Spotlight、CoverSutra 和其他该类型的应用程序。我设法创建一个自定义 NSStatusItem,它会弹出一个 NSWindow,但问题是当前具有焦点的应用程序会将焦点转移到我的自定义 NSWindow。
我以 Matt Gemmell 的示例为基础(http:// mattgemmell.com/2008/03/04/using-maattachedwindow-with-an-nsstatusitem)
例如,如果您在 Safari 中单击 Spotlight 图标,则当前 Safari 窗口不会变灰并保持不变专注。当您在 Spotlight 中按 ESC 时,焦点将返回到 Safari 窗口。
我还没有成功地用我的自定义 NSWindow 做到这一点。我必须单击返回窗口才能将焦点重新设置到该窗口。
所以我想知道要走哪条路才能实现这一目标。解决方案是带有自定义 NSMenuItem 的 NSWindow、NSPanel、NSMenu 吗?
I'm trying to create a LSUIElement app that behaves like Spotlight, CoverSutra and other apps of that type. I managed to create a custom NSStatusItem, which popups up an NSWindow but the problem is that the app that currently has focus will the focus to my custom NSWindow.
I've based myself on Matt Gemmell's example (http://mattgemmell.com/2008/03/04/using-maattachedwindow-with-an-nsstatusitem)
For example, if you're in Safari and click on the Spotlight icon, the current Safari window does not gray out and keeps focused. When you press ESC in Spotlight, the focus is back to the Safari window.
I haven't managed to do this with my custom NSWindow. I have to click back on a window to set focus back to it.
So I'd like to know which route to go to achieve this. Is the solution a NSWindow, NSPanel, NSMenu with a custom NSMenuItem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 NSPanel 和 NSNonactivatingPanelMask 作为 styleMask 或勾选 IB 中的选项。
Use NSPanel and NSNonactivatingPanelMask as styleMask or tick the option in IB.