Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a NSStatusItem to a specific position in NSStatusBar?

I use self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; to add an statusItem to the systemStatusBar on OSX. The statusItem then appears on the left-most position in the systemStatusBar. I was wondering if there is a way to add such an item to a specific index e.g. on the left side of the system clock?

like image 832
mxmln Avatar asked Nov 14 '13 10:11

mxmln


1 Answers

Yes and no. Using private API you can specify priority for adding NSStatusItem. I have developed a tiny category for NSStatusBar (NSStatusBar+MISSINGOrder) witch provides simple method for this:

NSStatusItem *statusItem =
    [systemStatusBar statusItemWithLength:NSVariableStatusItemLength
                               positioned:NSStatusBarItemOrderingModeAfter
                               relativeTo:NSStatusBarItemPriorityNotificationCenter];

You can look inside for implementation details.

like image 141
Valentin Shergin Avatar answered Sep 27 '22 17:09

Valentin Shergin