views:

26

answers:

1

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!

+1  A: 

Put the LSUIElement key in your app's info.plist. To do drag and drop, you set the status item's view to whatever view should receive the drop and it works normally from there on out.

Chuck
I'm going to try this out - looks as though it should be an ideal solution! I will post back with results!
Moddy