nsstatusitem

NSStatusBarButton keep highlighted

こ雲淡風輕ζ 提交于 2019-12-29 06:07:02
问题 As of OS X 10.10 most of NSStatusItem has been deprecated in favour of the button property, which consists of an NSStatusBarButton. It should work like a normal button but unfortunately the cell and setCell methods in NSStatusButton have also been deprecated. As a result of this I'm struggling to find a way to keep the button highlighted after it's clicked (Normally the button is highlighted on mouse down, and unhighlighted on mouse up. I want to keep it highlighted after mouse up). Calling

Get Notification of NSStatusItem frame change?

放肆的年华 提交于 2019-12-29 05:35:08
问题 In an app that uses a NSStatusItem with a custom view like this: ... how can you get notifications when: The status bar gets hidden because of a full screen app The status item moves position because another item is added/removed/resized? Both are necessary to move the custom view to the right position when the item changes places. 回答1: There is a method -[NSStatusItem setView:] . When you set a custom view for your status item, this view is automatically inserted into a special status bar

NSStatusItem releases icon

落花浮王杯 提交于 2019-12-24 20:22:37
问题 I have an ARC project involving a custom view that appears after clicking a status bar icon. I'm new to programming, so I pulled this example project from GitHub to get up and running. The app runs fine, the only issue is with the status bar item. I set up the NSStatusItem as I should, but as soon as I call setView, the icon seems to be released. I can click an empty space in the menubar which opens the app so the item is there, it's just that the icon is missing. (Image is confirmed to be

Detect click on OS X menu bar?

一曲冷凌霜 提交于 2019-12-23 00:51:31
问题 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? 回答1: You can install a local event monitor using NSEvent addLocalMonitorForEventsMatchingMask:handler: See the documentation located here. 来源:

Drag and Drop with NSStatusItem

我与影子孤独终老i 提交于 2019-12-17 17:33:19
问题 I'm trying to write an application that allows the user to drag files from the Finder and drop them onto an NSStatusItem . So far, I've created a custom view that implements the drag and drop interface. When I add this view as a subview of an NSWindow it all works correctly -- the mouse cursor gives appropriate feedback, and when dropped my code gets executed. However, when I use the same view as an NSStatusItem's view it doesn't behave correctly. The mouse cursor gives appropriate feedback

How to get the on-screen location of an NSStatusItem

*爱你&永不变心* 提交于 2019-12-17 15:36:46
问题 I have a question about the NSStatusItem for cocoa in mac osx. If you look at the mac app called snippets (see the movie at http://snippetsapp.com/). you will see that once you clicked your statusbar icon that a perfectly aligned view / panel or maybe even windows appears just below the icon. My question is ... How to calculate the position to where to place your NSWindow just like this app does? I have tried the following: Subclass NSMenu Set the view popery for the first item of the menu

How to change NSStatusItem out of class

≯℡__Kan透↙ 提交于 2019-12-12 04:54:30
问题 I create a NSStatusItem in a class named StatusMenuController like this class StatusMenuController: NSObject { let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength) override func awakeFromNib() { let icon = NSImage(named: "MenuBar") icon?.isTemplate = true // best for dark mode if let button = statusItem.button { button.image = icon button.action = #selector(StatusMenuController.showPomoNow) button.sendAction(on: [.leftMouseUp, .rightMouseUp]) button.target

NSStatusBar drag & drop with menu

不想你离开。 提交于 2019-12-11 11:53:43
问题 I'm familiar with the technique described here: Drag and Drop with NSStatusItem to make an NSStatusBar item that can handle file drag & drop. What is the proper method for having a status bar item that supports both drag & drop and regular menu interactions, much like the Cloudapp icon does. I want users to be able to left click the NSStatusItem to see the normal menu listing as well as allow for file drag and drop functionality. It seems to me like I have to write all my own click handler

Double-click action for menu bar icon in Mac OSX

三世轮回 提交于 2019-12-11 06:53:18
问题 I'm writing a small Mac OSX app that displays a menu bar icon. When clicked, a menu pops up. I'd like to have a "default" action for the menu bar icon. Basically, to execute an action when double-clicking it, without having to select the action from the menu. I looked over the Apple docs and there's is such a thing in NSStatusItem called doubleAction , but it's soft deprecated and does not (seem to) work. More over, the docs it says to use the button property, but trying to do so results in

Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

只愿长相守 提交于 2019-12-10 10:42:07
问题 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