views:

76

answers:

1

Hi,

I'm working on an app that displays certain information on the status menu, and I was wondering if there's any Cocoa API that can make my NSStatusItem always placed on the most-left, no matter when it's started or if other apps are started after it.

NSStatusBar *bar = [NSStatusBar systemStatusBar];
barItem = [[bar statusItemWithLength:NSVariableStatusItemLength] retain];

Thanks.

+2  A: 

Taking you ultra-literally for a moment, what if two applications used such an API? They would fight and roll off the end of the menu bar. ☺

There is no supported way to do it, but there is an undocumented/unsupported way to specify the “priority” of the status item when you create it. Of course, use at your own risk, and be sure to do a respondsToSelector: checck to fall back on the supported way if the unsupported way goes away.

Peter Hosey
I was quite sure that the operating system imposes "all are equal" rules when adding status bar items, but there's always an "undocumented way"..Thanks for your answer and your help.
alex