nsstatusbar

How to open a NSPopover at a distance from the system bar?

半世苍凉 提交于 2019-11-30 16:09:49
问题 I'm opening a NSPopover with the action of an icon in the status bar. myPopover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY) This works fine with the exception that the distance from the popover and the system bar is zero: I'd like to achieve the same result as the Dropbox app which renders the popover at a small distance from the system bar: I've tried using button.bounds.offsetBy(dx: 0.0, dy: 20.0) which doesn't affect the position of the popover and button

How to update NSMenu while it's open?

一个人想着一个人 提交于 2019-11-30 05:45:54
问题 I have a NSMenu with dynamically added NSMenuItems. The NSMenu is not refreshing properly while it's kept open. I am calling NSMenu update method in NSEventTrackingRunLoopModes . I have implemented following methods to update NSMenu. - (void)menuNeedsUpdate:(NSMenu *)menu { for (NSInteger index = 0; index < count; index++) [self menu:menu updateItem:[menu itemAtIndex:index] atIndex:index shouldCancel:NO]; } - (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)item atIndex:(NSInteger)index

How to drag NSStatusItems

我的未来我决定 提交于 2019-11-29 01:30:50
问题 You all know the menu bar (or better said NSStatusBar) in Mac OS X. There are some items which I can move and other which not. I would like to be able to drag the NSStatusItem of my app. Any idea how to implement this? 回答1: Although NSStatusItems appear near Apple's internal "menu extras", they are distinct and behave differently. It would be nice if Apple unified the items that can appear in the right-hand area of the menu bar, but for now the section is split into distinct "apple internal"

How to get frame for NSStatusItem

℡╲_俬逩灬. 提交于 2019-11-28 21:40:52
Is it possible to get the frame of a NSStatusItem after I've added it to the status bar in Cocoa? When my app is launched, I am adding an item to the system status bar, and would like to know where it was positioned, is possible. If you have set a custom view on the status item: NSRect statusRect = [[statusItem view] frame]; NSLog(@"%@", [NSString stringWithFormat:@"%.1fx%.1f",statusRect.size.width, statusRect.size.height]); Otherwise I don't think it's possible using the available and documented APIs. Edit: Incorporated comments. The following seems to work - I have seen similar solutions for

NSStatusItem change image for dark tint

纵饮孤独 提交于 2019-11-28 16:01:06
With OSX 10.10 beta 3, Apple released their dark tint option. Unfortunately, it also means that pretty much all status bar icons (with the exception of Apple's and Path Finder's that I've seen), including mine, remain dark on a dark background. How can I provide an alternate image for when dark tint is applied? I don't see an API change on NSStatusBar or NSStatusItem that shows me a change, I'm assuming it's a notification or something reactive to easily make the change as the user alters the tint. Current code to draw the image is encased within an NSView : - (void)drawRect:(NSRect)dirtyRect

How to get frame for NSStatusItem

坚强是说给别人听的谎言 提交于 2019-11-27 14:05:50
问题 Is it possible to get the frame of a NSStatusItem after I've added it to the status bar in Cocoa? When my app is launched, I am adding an item to the system status bar, and would like to know where it was positioned, is possible. 回答1: If you have set a custom view on the status item: NSRect statusRect = [[statusItem view] frame]; NSLog(@"%@", [NSString stringWithFormat:@"%.1fx%.1f",statusRect.size.width, statusRect.size.height]); Otherwise I don't think it's possible using the available and

NSStatusItem change image for dark tint

ぐ巨炮叔叔 提交于 2019-11-27 09:30:09
问题 With OSX 10.10 beta 3, Apple released their dark tint option. Unfortunately, it also means that pretty much all status bar icons (with the exception of Apple's and Path Finder's that I've seen), including mine, remain dark on a dark background. How can I provide an alternate image for when dark tint is applied? I don't see an API change on NSStatusBar or NSStatusItem that shows me a change, I'm assuming it's a notification or something reactive to easily make the change as the user alters the