2

I've created an NSStatusItem for my app, but would like it to be navigable, as the system items are, when using Control+F8 (Control+fn+f8).

The status item is inexplicably skipped in the navigation sequence. Is there a secret handshake of accepting first responder or something that needs to be done for this?

This is basically all the setup code I have for the item:

statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(28)
statusItem.menu = menu
statusItem.button?.image = NSImage(named: "menuIcon")
Daniyar
  • 2,975
  • 2
  • 26
  • 39
voidref
  • 1,113
  • 11
  • 15

2 Answers2

2

I found a a similar question asked on 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.

Quoting Colin Barrett:

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.

So if you really want to make your status menu items available via keyboard you'll have to dig within Apple's private frameworks, however that's an unstable territory, as they're subject to change at any time, without any notification.

Cristik
  • 30,989
  • 25
  • 91
  • 127
  • UGH, time for a radar. This is a serious accessibility issue. – voidref Apr 27 '15 at 21:24
  • If I correctly remember you can access the status item via the accessibility API (I wrote a little QA automation library based on the accessibility API a while ago and I was able to programatically access the status item) – Cristik Apr 27 '15 at 21:28
0

As of at least macOS 10.12, it is possible to navigate to an NSStatusItem using the keyboard with Control+F8. This change presumably occurred between OS X 10.10 and macOS 10.12 (I haven’t tested this with any versions earlier than 10.12).

In order to enable keyboard navigation, the NSStatusItem’s menu property must be defined.

Teddy
  • 11
  • 3