Questions tagged [nsstatusbar]

The NSStatusBar class defines an object that manages a collection of NSStatusItem objects displayed within the system-wide menu bar.

The NSStatusBar class defines an object that manages a collection of NSStatusItem objects displayed within the system-wide menu bar. A status item can be displayed with text or an icon, can provide a menu and a target-action message when clicked, or can be a fully customized view that you create.

Use status items sparingly and only if the alternatives (such as a Dock menu, preference pane, or status window) are not suitable. Because there is limited space in which to display status items, status items are not guaranteed to be available at all times. For this reason, do not rely on them being available and always provide a user preference for hiding your application’s status items to free up space in the menu bar.

94 questions
5
votes
1 answer

OSX Status Bar Image Sizing - Cocoa

So i'm having a problem with the image of a NSStatusBar item, it seems like the image is pushing away from the rest of the menu items as you can see in this picture. But when the menubar is inactive (as in i'm on my other monitor or not in the app)…
Bolt Sandwich
  • 65
  • 1
  • 6
4
votes
1 answer

How to get all NSStatusItem elements of NSStatusBar in OSX?

I need get all elements in the status bar in OSX. I tried to get the NSStatusBar id of the System: [NSStatusBar systemStatusBar] but I don't know how can I get all NSStatusItems in it. I found a private method named _items in NSStatusBar but I can't…
4
votes
1 answer

Save preference to show or hide NSStatusItem

I've got an application which runs as a normal app but also has a NSStausItem. I wanted to implement the ability to set in the preferences a checkbox and when this checkbox is turned on the status item should be shown, but when the checkbox is off…
dehlen
  • 7,325
  • 4
  • 43
  • 71
4
votes
0 answers

NSStatusBar loses state

Some time ago I wrote an app using NSStatusBar to put a menu in the status bar. This had ever been working nicely. I did not use it for 2 or 3 years (so I guess in Yosemite it worked well). Now, when I run it in High Sierra it does lose state…
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
4
votes
1 answer

NSStatusBar + Swift: title shows and immediately disappear

I want make status bar for macOS, but after I run application title shows and immediately disappears func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application let…
kesrut
  • 662
  • 1
  • 9
  • 25
4
votes
3 answers

Swift 2.2 selector in NSMenuItem

I have a simple one file menu bar app in swift: import Cocoa class StatusBarApp : NSObject { func buildMenu() { let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength) statusItem.title =…
lutrekubej
  • 63
  • 1
  • 3
4
votes
2 answers

Highlight NSStatusItem when triggered programmatically

I have an NSStatusItem with an attached menu that I'm triggering with a global hotkey. If I click the menu item I get the highlight as usual, if I use the hotkey the highlight isn't triggered. Does anyone know a way to trigger the highlight? I've…
twe4ked
  • 2,832
  • 21
  • 24
3
votes
1 answer

Detect click on OS X menu bar?

I'm curious if there's a trick to detecting a click on the Menu Bar as a whole. I know I can detect a click on an NSStatusItem or NSMenu, but I am looking for events pertaining to the empty space of the Menu Bar. Looking through the documentation,…
akaru
  • 6,299
  • 9
  • 63
  • 102
3
votes
3 answers

Statusbar.image has wrong color

I am using following code for my status bar image: let icon = NSImage(imageLiteralResourceName:"flag") statusBarItem.image = icon This leads to wrong color for certain background colors / modes. In the picture, what's white should be black. The…
user688262
  • 171
  • 11
3
votes
1 answer

NSStatusItem's menu are not shown in Full Screen Model for the Mac os 10.13.1

all: I have added one NSStatusItem in the status bar for my test app, and it works well in Mac ox 10.12, not only normal model, but also full screen model. When i switch to Mac os 10.13, it is failed to show the menu in the full screen…
stream hu
  • 41
  • 3
3
votes
1 answer

NSClickGestureRecognizer not working on NSStatusItem

Trying to recognize a right click on a NSStatusItem I got a suggestion ( Thanks to Zoff Dino ) to use a NSClickGestureRecognizer for that. But for some bizarre reason it isn't working as it should be. I am able to recognize a left click (buttonMask…
Devapploper
  • 6,062
  • 3
  • 20
  • 41
3
votes
1 answer

NSStatusBar with NodObjC

I'm trying to create a cocoa app with Node.js using NodObjC. I have been creating an app which runs on only MacOS X as HTTP server. NodObjC https://github.com/TooTallNate/NodObjC I want to show the server status with icon on StatusBar like this. I…
wf9a5m75
  • 6,100
  • 3
  • 25
  • 59
3
votes
1 answer

Mac System Status Bar Focus

I've added a menu to my systemStatusBar by this code: statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; And then set its properties. The only different it has with other status items (Volume,…
Abcd Efg
  • 2,146
  • 23
  • 41
2
votes
1 answer

NSAppearance is not updating when toggling dark mode

I have a macOS app that runs only in the macOS status bar. I changed the "Application is agent (UIElement)" property in the Info.plist to "YES": LSUIElement I have a timer that prints out the appearance's name every 5 seconds…
Lukas Würzburger
  • 6,543
  • 7
  • 41
  • 75
2
votes
1 answer

Force NSStatusItem to Redraw

I create a NSStatusItem and add an image. After the image has been added, changing the image.template property has no immediate effect on the icon. Only after clicking the status item does the image become a template. Is there a way to force the…
Kyle Berezin
  • 597
  • 4
  • 20