我已经为我的应用程序创建了一个 NSStatusItem,但希望在使用 Control+F8 (Control+fn+f8) 时它可以像系统项目一样可导航。
状态项在导航序列中莫名其妙地被跳过。是否有接受第一响应者的 secret 握手或需要为此做些什么?
这基本上是我对该项目的所有设置代码:
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(28)
statusItem.menu = menu
statusItem.button?.image = NSImage(named: "menuIcon")
最佳答案
我在 quoara.com 上发现了一个类似的问题:http://www.quora.com/Why-cant-I-focus-third-party-icons-in-the-status-menu-area-on-OS-X-with-a-keyboard-shortcut-like-Ctrl-F8-SOLVED .
引用科林·巴雷特:
The third party items are implemented with a different API (NSStatusItem) than the built-in ones (NSMenuExtra). Note that you can drag to re-arrange the menu extras but not the status items (which always appear to the left of menu extras).
Unfortunately NSMenuExtra is private API and with the Mac App Store you're likely to see less and less apps using it.
Just as an example of third party apps which do support this, you can probably F8 to the MenuMeters icon / graph.
因此,如果您确实想让状态菜单项通过键盘可用,您必须在 Apple 的私有(private)框架内进行挖掘,但这是一个不稳定的领域,因为它们可能随时更改,而不会发出任何通知。
关于macos - NSStatusItem 无法通过键盘导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29888032/