nsstatusitem

Detect click on OS X menu bar?

偶尔善良 提交于 2019-12-06 10:42:55
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, it does not seem possible. However, I wanted to know if anyone had a workaround for this functionality? You can install a local event monitor using NSEvent addLocalMonitorForEventsMatchingMask:handler: See the documentation located here . 来源: https://stackoverflow.com/questions/7249239/detect-click-on-os-x-menu-bar

Cocoa - Capturing NSStatusItem mouse hover event

扶醉桌前 提交于 2019-12-06 10:24:39
How do I execute a function when a user's mouse hovers over my NSStatusItem? If you assign a custom NSView to your NSStatusItem 's view property, you can override the NSResponder methods mouseEntered: , mouseMoved: and mouseExited: . 来源: https://stackoverflow.com/questions/5114974/cocoa-capturing-nsstatusitem-mouse-hover-event

NSStatusItem with NSPopover and NSTextField

夙愿已清 提交于 2019-12-06 10:23:49
问题 I have a NSStatusItem that displays a NSPopover which contains a NSTextField but the text field isn't editable although it has been so be so in Xcode. Now this is a known bug and there is apparently a solution someone posted here. I really need to work around this bug. I'll just quote the answer here for convenience: The main problem is the way keyboard events works. Although the NSTextField (and all his superviews) receives keyboard events, he doesn't make any action. That happens because

Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

孤街醉人 提交于 2019-12-06 05:33:00
I have a Status-Bar item only app that Iam trying to get to show a panel on mouseOver. I have the custom status item (and associated view) hooked up and working, but the tracking rect is only receiving events on every dozen or so launches. This leads me to believe there is a race condition happening somewhere, but I can't find it. In my custom status bar item view: - (id)initWithStatusItem:(NSStatusItem *)statusItem { CGFloat itemWidth = [statusItem length]; CGFloat itemHeight = [[NSStatusBar systemStatusBar] thickness]; NSRect itemRect = NSMakeRect(0.0, 0.0, itemWidth, itemHeight); NSLog(@

Weird behavior: dragging from Stacks to status item doesn't work

会有一股神秘感。 提交于 2019-12-06 05:09:47
问题 My application allows dragging to both the main window and to a Status item. If I drag a file from Stacks to my window, it works perfectly. If I drag a file from Finder to my window, it works perfectly. If I drag a file from Finder to my status item, it works perfectly. If I drag a file from Stack to my status item, it doesn't work. Both window and status item use the exact same drag and drop handling code. The funny thing is that when a file is dragged from Stacks onto the status item, the

Display image in a cocoa status app

瘦欲@ 提交于 2019-12-05 19:02:44
问题 Hi I developed a cocoa status app. when I put a long title for example , it can't be shown and if i put an image as icon too it can't be shown , but if i put a small title it works correctly. How can I fix this problem and make the image shown? statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; [statusItem setMenu:menu]; //[statusItem setTitle:@"Notif "]; [statusItem setImage:[NSImage imageNamed:@"image"]]; [statusItem setHighlightMode:YES];

Highlight NSStatusItem when triggered programmatically

依然范特西╮ 提交于 2019-12-05 17:00:42
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 tried overriding the view and drawing it myself in drawRect but if there is a nicer way to do it I'd love to hear. Thanks! The reason I don't want to override the view is then I have to handle icon positioning, clicking to activate the menu, etc. This does the magic in macOS 10.13.6 with Xcode 10. guard let m = statusItem.menu else { return }

How do I use an indeterminate status indicator as the image for an NSStatusItem?

孤街浪徒 提交于 2019-12-05 14:47:11
I have an application that is an NSStatusItem . It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen. I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X. Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator ?) or must I manually display an animation by cycling through a set of images? In either case, how would I implement? In order to

How can I vertically align my status bar item text?

落花浮王杯 提交于 2019-12-05 02:34:13
Left one on the picture is the date and time from Apple and one is my application one. As you may see the text of my application appears lower than the Apple one. Which doesn't look pretty. How can this be resolved? self.statusBarItem.image = nil self.statusBarItem.button?.imagePosition = .NoImage self.statusBarItem.button?.title = "Sun 5 Jun 13:35" Tarvo Mäesepp You could do it in offset. You cannot do it like this since it needs to be done on the status item button bar. button.frame = CGRectMake(0.0, 0.5, button.frame.width, button.frame.height) I wanted to make a quick addition to this.

Cocoa - How to bring particular window to come in foreground from StatusMenu

不打扰是莪最后的温柔 提交于 2019-12-04 20:12:52
I am working on an Mac Application. I have set Application is agent (UIElement) = YES in plist, and App have a Window (lets say Popup Window) that acts as custom PopOver for StatusMenu. One more window is there (lets say Window B) that should opened on selecting a Link from StatusMenu that i have made, but Problems that I am facing are as follow: On Application launch, When I opens status Menu It also showing Window B , that actually should not be Shown. Window B is allocated and initialised in Application Delegate. Another Issue is When Window B is made Visible by Selecting it from StatusMenu