PDA

View Full Version : Menubar icons HOWTO


aishafenton
January 25th, 2002, 06:10 PM
Hi,

Does anyone know how to create a menu bar extra (like the clock/display menubar icons).

Is there an API for this? Is there some documentation on how to create an application like this anywhere??? I have looked http://developer.apple.com and couldn't find anything.


Thanks heaps,

Ghoser777
January 26th, 2002, 06:04 PM
1. Install Developer Tools

2. Build project in /Developer/Examples/AppKit/MenuMaddness/

3. Tremble in awe

;)

HTH,
F-bacher

aishafenton
January 27th, 2002, 09:33 PM
Hi,

Thanks for your reply. However I don't mean fancy menu widgets, but rather I want to create a "menu extra" application.

Menu extras are the new application types that came with 10.1, such as clock.menu and display.menu.

I believe the API for this is undocumented, but people has reverse engineered it, and are using it. Does anyone know how to create one of these apps???

Thanks

seb2
January 28th, 2002, 03:55 AM
ok, no idea about .menu, but making an app put a menu up there like netmonitor does is quite easy; nsstatusbar is what you're looking for then.

there's a good example which you can find here: http://www.ultraviolent.com/cocoa/demos/globalmenu/

Ghoser777
January 28th, 2002, 01:07 PM
Whoops!

Sorry to disapoint you, but the .menu api is private, so you're not technically suppose to make them. The api can change without warning, so it could become a hassle at some point. The best way to find a solution is to contact a developer of on of the apps that use the private api.

HTH,
F-bacher

aishafenton
January 28th, 2002, 11:40 PM
It's a shame the API is private... I can see why Apple has always thought that the menubar is their property and shouldn't really have third party apps cluttering it up.

But since in 10.1 they have given us back the very useful control strip and have put it in the menubar... it makes it very tempting to use it.

Esp.. since some apps just DON'T need to take up dock space. Why I am interested in it is that I use a small open source VPN connection utility called PPTP-GUI to connect to the internet

This sits in the dock showing me that I am connected... it serves the same purpose as PPP, PPPoE which Apple have made .menu apps for.. so why shouldn't it sit up in the menubar too???

Oh well perhaps Apple will extend the API and then let everyone use it someday.

Ghoser777
January 29th, 2002, 12:47 AM
What you could do is make an app that uses teh NSStatusBar and doesn't have any of the normal gui elements.... I can't remember exactly how to set it up. I think you set NSUIElement to 1. I'm not sure if that would disable the NSStatusBar or not (it's quite possible), but atleast the icon wouldn't show up in the dock.

F-bacher

seb2
January 29th, 2002, 02:43 PM
"net monitor" does it, so it has to be possible... don't ask me whether they dynamically change the nsuielement at runtime, but they somehow do it.

great app anyway, i have it in my statusbar, no dock icon, no nothing, just the network traffic.

tie
January 29th, 2002, 07:19 PM
Originally posted by Ghoser777
What you could do is make an app that uses teh NSStatusBar and doesn't have any of the normal gui elements.... I can't remember exactly how to set it up. I think you set NSUIElement to 1. I'm not sure if that would disable the NSStatusBar or not (it's quite possible), but atleast the icon wouldn't show up in the dock.

F-bacher

This hides the dock icon and the application's menu bar. So you basically get a floating window. Make it float in front of all windows (see NSWindow) including the menu-bar, make it semi-transparent and hide the window title, and you've got an easy menu-bar widget.

Unfortunately, this does not adjust itself to fit with the other menu-bar widgets. So you'd have to have the user manually place the window in the correct place in the menu bar (e.g., by dragging it). This might not be so annoying since they'd only have to do it once, but still it's not perfect.

Matrix Agent
January 29th, 2002, 08:05 PM
I think it's great that the API is closed. It just allows for too much bloatware if apps can come and leave as they please. It might end up looking like the small module bar on MS's machines. Ouch.

aishafenton
January 29th, 2002, 09:26 PM
BUT.....

There is quite a key difference between the window's sys-tray and Menu-extra API. The reason the windows sys-tray gets so bloated is that the user doesn't have much control over what apps decide to put there stupid icons there.. which I agree really sucks.

The menu-extra API works by the user dragging the app onto the menu bar to put it there, and if they get sick of it they can always drag it right off.

For example if you'd like a network monitor menu-extra just drag the monitor.menu app on to the menubar.. and it'll place itself there and start. You can even adjust were in the menubar you'd like it. If you get sick of it just drag it off, and it'll stop the app and remove the menu icon.

So it actually gives more control to the user than the what is currently allowed! It would only get bloated if the user wants to have umpten icons there.. if you don't, then just don't put them there.

Ghoser777
January 29th, 2002, 11:25 PM
Originally posted by tie


This hides the dock icon and the application's menu bar. So you basically get a floating window. Make it float in front of all windows (see NSWindow) including the menu-bar, make it semi-transparent and hide the window title, and you've got an easy menu-bar widget.

Unfortunately, this does not adjust itself to fit with the other menu-bar widgets. So you'd have to have the user manually place the window in the correct place in the menu bar (e.g., by dragging it). This might not be so annoying since they'd only have to do it once, but still it's not perfect.

That's what some of the original menu clock replacements use to do. I wouldn't suggets doing it now, since it won't be placed properly most of the time. What I'm wondering is if the NSStatusBar element gets hidden when you set NSUIElement to 1 (or 0, whichever it is). I'm not exactly sure, but it might be hidden along with the rest of the menuItems in the menu bar. Sounds like something to check, though.

F-bacher