nsstatusitem

Misaligned NSAttributedString in macOS NSStatusItem's button

陌路散爱 提交于 2021-02-11 15:05:01
问题 I would like to display a two-line NSAttributedString as the button title of the NSStatusItem of my macOS app. However, it seems to move the text up a few pixels and, thus, cut it off. This problem did not occur before macOS Big Sur. Workaround With some effort I managed to generate an NSImage of the text and use it as the button's image. Question Is there any way to position the NSAttributedString correctly without using an image? 来源: https://stackoverflow.com/questions/65167179/misaligned

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

家住魔仙堡 提交于 2021-02-08 13:11:38
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

余生长醉 提交于 2021-02-08 13:10:54
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

NSDatePicker in NSStatusBar NSSMenuItem not receiving input

ⅰ亾dé卋堺 提交于 2021-02-08 13:09:01
问题 A while back I wrote a simple calendar menu bar widget called Day-O. The calendar uses the stock NSDatePicker nested inside an NSView inside an NSMenuItem in an NSMenu added to an NSStatusItem. The app has an activationPolicy of .accessory (originally set via the plist's "Application is agent" bool). At some point (maybe with the El Capitan update?) the calendar stopped responding to input. When the app first launches you can click the status bar item to expand the menu and interact with the

Highlighting NSStatusItem with attributed string

纵饮孤独 提交于 2021-01-27 04:14:31
问题 I have a NSStatusItem, and I use an attributed string for it, setting is as such: [statusItem setAttributedTitle:as]; where as is my attributed string. I use it to highlight certain parts of the item when certain conditions are met by coloring them differently. So my status item can have some red text and some black text, for example. Now the problem is, when I use setAttributedTitle and then click on the status item, the colors don't get inverted as I want them to. For instance, when I used

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

纵然是瞬间 提交于 2021-01-21 04:08:08
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

↘锁芯ラ 提交于 2021-01-21 04:07:07
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

孤人 提交于 2021-01-21 04:06:26
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

NSStatusItem Button Title to the Right of the Image

試著忘記壹切 提交于 2020-11-29 08:34:11
问题 I want an NSStatusItem ’s button’s title to appear to the right of its image. Here’s an example, this is the OS X VPN menubar app: If I set either the title or image for my NSStatusItem ’s button, they render correctly. However if I set both , they get superimposed and are horizontally center-aligned. Is there a way to achieve the side-by-side placement without creating a custom UIView ? 回答1: This has to do with a change in Yosemite, which deprecated setTitle: and setImage: on NSStatusItem .