nsstatusitem

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

Cocoa: Right Click NSStatusItem

随声附和 提交于 2019-11-27 12:55:46
I am a .Net developer who need to port a small project into Mac, so I know next to nothing about Objective C. In fact the code below was just a bunch of grasping at straws and shooting in the dark. Trying to build a Status Menu program that opens one or another window depending on if it is a left-click or a right-click/ctrl+click. Here is what I have, and it works for left-click only (obviously): -(void) awakeFromNib{ NSBundle *bundle = [NSbundle mainBundle]; statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; [statusImage = [[NSImage alloc]

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

Being apprised of when NSStatusItem is hidden

让人想犯罪 __ 提交于 2019-11-27 02:51:40
问题 I have an app which uses an NSStatusItem . On small screens there's not much space in the status bar. When a user switches to an application with a lot of menu items, my status item gets hidden. Is there a way to get notified about this? What I tried so far: I checked if any NSNotification is fired: No I checked if the statusView is removed from the view hierarchy: No I checked isHiddenOrHasHiddenAncestor : No Here's the code I use to create the status item. self.statusItem = [[NSStatusBar

Cocoa Keyboard Shortcuts in Dialog without an Edit Menu

♀尐吖头ヾ 提交于 2019-11-26 18:49:45
问题 I have an LSUIElement application that displays a menubar status item. The application can display a dialog window that contains a text field. If the user right-clicks/control-clicks the text field, a menu appears that allows cut, copy, paste, etc. However, the standard Command-X, Command-C, and Command-V keyboard shortcuts do not work in the field. I assume this is because my application does not provide an Edit menu with those shortcuts defined. I've tried adding an Edit menu item to my

Cocoa: Right Click NSStatusItem

你离开我真会死。 提交于 2019-11-26 18:14:13
问题 I am a .Net developer who need to port a small project into Mac, so I know next to nothing about Objective C. In fact the code below was just a bunch of grasping at straws and shooting in the dark. Trying to build a Status Menu program that opens one or another window depending on if it is a left-click or a right-click/ctrl+click. Here is what I have, and it works for left-click only (obviously): -(void) awakeFromNib{ NSBundle *bundle = [NSbundle mainBundle]; statusItem = [[NSStatusBar