Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmd + click to move status item

The built in battery, wi-fi, sound, etc, Apple supplied status items, can be dragged to any position on the menu by using cmd + click and drag:

How can I support similar functionality in my own status item?

like image 900
rid Avatar asked Jul 03 '12 21:07

rid


1 Answers

There are two ways to get menus on the right side of the menu bar. The officially supported way is creating an NSStatusItem in your app. The other ways is creating an NSMenuExtra. You've noticed one difference: NSStatusItem menus are fixed in place, whereas the menu extras can be moved around by cmd-dragging them.

The other major difference, and the reason 3rd-party menu extras are not officially supported, is that unlike status items (which run as separate applications), menu extras are loaded into the address space of the SystemUIServer process. That means if they go haywire and crash, they can take down the UI.

You can see the Menu Extras installed on your system at /System/Library/CoreServices/Menu Extras. It may still be possible to create your own and have the OS load them, but you will run into problems if you try to ship the result. Better to go to bugreport.apple.com and let them know that NSStatusItems ought to be draggable.

Wikipedia has more info on Menu Extras, including some links to a tutorial on building your own.

like image 62
benzado Avatar answered Sep 20 '22 21:09

benzado