Mac OS X Status Bar Application - Hiding it from Cmd/Alt menu?

Posted by Moddy on Stack Overflow See other posts from Stack Overflow or by Moddy
Published on 2010-06-07T15:29:18Z Indexed on 2010/06/07 15:32 UTC
Read the original article Hit count: 259

Filed under:
|
|

I'm trying to whip up a simple little Status Bar Application in Obj-C/Cocoa.

So I have done it pragmatically - declaring an NSStatusItem, adding it to the NSStatusBar and then giving it a NSMenu object. A bit like this...

NSStatusBar *bar = [NSStatusBar systemStatusBar];

theItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[theItem retain];

[theItem setTitle: NSLocalizedString(@"Tablet",@"")];
[theItem setHighlightMode:YES];
[theItem setMenu:theMenu];

(Example taken from "Status Bar Programming Topics", Apple Documentation)

Now ideally, I'd like this application to run and not be accessible from the CMD/ALT window changing "menu" (for lack of a better word), I've seen applications do it before and would like that really. The idea is I just want it to be accessible from every window, whilst not having its own NSMenu on the status bar, and whilst not being able to have it as the active application ( - so its not able to take over the whole Status Bar, and its not able to be seen through CMD/ALT)

Additionally, I was wondering if the StatusBarItem supports the ability to drag-n-drop an item onto it? I'm not sure if thats a limitation of the NSStatusBar though.

I've read up on deamons and agents, but that seems far too low level/over kill for such a simplistic app!

Cheers in advance!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about macosx