gpt4 book ai didi

macos - NSStatusItem 不是键盘可导航的

转载 作者:可可西里 更新时间:2023-11-01 01:40:52 27 4
gpt4 key购买 nike

我已经为我的应用程序创建了一个 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com