How to code a system menu bar item?

michaelsanford

Translator, Web Developer
I want to make a little, lightweight customizable application to back up my files to various media (my USB stick, FireWire drive, ftp folders, etc).

Looking through the PB default applicaiton types I don't see anything that looks like it would give me an icon in the SystemUIServer (or the menu bar to be less specific).

Do I have to construct my own .menu item from scratch?

Incidentally, I also have MenuMeters installed, but it doesn't behave the same way as the Apple menu extras (i.e., I can't command-drag it out of the menu bar, or move it along the menu bar)...

If anyone has any sample code, that would be the best! I can't find any GNU manu bar apps as of yet...

Thanks!


(PS: How appropriate this is my 1024th post :p )
 
Have you checked Apple's Developer Center? They have lots of sample code.
 
That's because Apple pretty much banned us from making menu extras (the NSMenuExtra code that .menus use is part of a private framework) BUT they do allow us to use NSStatusItem. The only thing about it is that you have to make an application rather than a .menu bundle, and as you mentioned above, you can't command drag it around.

Means you'll have to remember to start up that application (or just add it to your login items).

Here's a pretty good tutorial on NSStatusItems: Recent Tunes NSStatusItem. It gives the basics pretty well (and it'll show ya how to use Applescript inside an app as well, which is pretty cool too).
 
Email Aladdin and ask how they did it.

I wish Apple would stop trying to restrict us from modifying different portions of the OS. Oh well, maybe when it's more fully settled.
 
In this case, mainly it's because menu extras run under the SystemUIServer process, and any third party ones can cause it to crash. They don't want to have to bother with that.
 
Wow thanks guys, lots of great responses.

I'll take a closer look at ADC, but I'm not really fluent in Obj-C so making all sorts of constructs from scratch is going to take me a long time hehe.
 
Back
Top