PDA

View Full Version : Menubar...




mbabauer
Sep 11, 2006, 09:24 PM
I am playing around with Cocoa, and read through a couple of books, but none of them show you how to add an app that runs in the Menubar (Task Tray???) like QuickSilver or Backlight does. Obviously it can be done, but how? A search in the Apple Developers docs for 'menubar' turns up a ton of references to Tk menus, but not really what I need.



mbabauer
Sep 12, 2006, 08:25 AM
Ok, finally got some leads in the docs and Google. There are actually two places this can be done, as an NSMenuExtras or as a NSStatusItem.

The problem is that apparently NSMenuExtras is a closed API, and NSStatusItem is not guaranteed to be there, as long menu items can overwrite status items if they need space.

There are some workarounds, although I am not clear how they fully work, but they seem to be more like hacks than legit code.

Anyone have any sample code that puts a Status Item up with no menu or window? I am trying to do something similar to QuickSilver (in layout, not functionality) where there is an icon on the right of the menu bar that does something when you click it.

savar
Sep 12, 2006, 09:30 AM
The problem is that apparently NSMenuExtras is a closed API, and NSStatusItem is not guaranteed to be there, as long menu items can overwrite status items if they need space.

I had the same problem several years ago. Back then there were rumors that NSMenuExtras would be made public for 3rd party developers to use. Guesss that never happened.

Using NSStatusItem isn't too bad. I don't have the code anymore, but I think I found it on cocoadevcentral.com.

Fairly
Sep 24, 2006, 06:06 PM
I am playing around with Cocoa, and read through a couple of books, but none of them show you how to add an app that runs in the Menubar
That's cos you didn't get the one Cocoa book you need. By Yacktman.