开发者

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

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 i开发者_开发问答ts 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜