Reputation: 473
I am trying to add a functionality to my status bar app for Mac OS X. I would like to be able to move my item along the bar, as you can do for the native OS tools like the Bluetooth or the WiFi icon.
Cheers
Upvotes: 1
Views: 503
Reputation: 1328
Update for macOS Sierra: Apple improved NSStatusItem
. Items can now be reordered by ⌘-dragging. This works for all Apple’s menu items and all third party apps.
Pretty much all the reasons you could ever want to use NSMenuExtra
have been removed now, which is great. So, the answer now is to just use NSStatusItem
. No further action is required.
Upvotes: 2
Reputation: 2960
What you are looking for is NSMenuExtra
and not NSMenuItem
.
Apple uses NSMenuExtra
for the system menu icons including Wi-Fi and Bluetooth. Although it looks similar to the regular NSMenuItem
, NSMenuExtra
has some special features, notably to keep their relative order after rebooting, and Command-Draggable by user.
Unfortunately, NSMenuExtra
is totally undocumented, so if you are targeting the Mac App Store, it's better for you to stick with the standard NSMenuItem
. Otherwise, there is a bunch of tutorials about how to create an NSMenuExtra
. For example, here are two of them:
Upvotes: 1
Reputation: 14160
Unfortunately there is no 'good' way to do that, however you can check this question for the hack which can do that:
Upvotes: 0