nsstatusitem

NSMenuItem is not enabled swift

倖福魔咒の 提交于 2020-04-08 10:37:10
问题 I have a NSMenuItem in my project: var statusBar = NSStatusBar.systemStatusBar() var statusItem : NSStatusItem = NSStatusItem() var menuItem : NSMenuItem = NSMenuItem() var mainMenu = NSMenu() override func viewDidLoad() { super.viewDidLoad() menuItem.title = "Holidays" menuItem.action = Selector("setWindowVisible:") menuItem.target = nil menuItem.keyEquivalent = "M" menuItem.enabled = true mainMenu.addItem(menuItem) statusItem = statusBar.statusItemWithLength(-1) statusItem.menu = mainMenu

NSMenuItem is not enabled swift

时光怂恿深爱的人放手 提交于 2020-04-08 10:37:06
问题 I have a NSMenuItem in my project: var statusBar = NSStatusBar.systemStatusBar() var statusItem : NSStatusItem = NSStatusItem() var menuItem : NSMenuItem = NSMenuItem() var mainMenu = NSMenu() override func viewDidLoad() { super.viewDidLoad() menuItem.title = "Holidays" menuItem.action = Selector("setWindowVisible:") menuItem.target = nil menuItem.keyEquivalent = "M" menuItem.enabled = true mainMenu.addItem(menuItem) statusItem = statusBar.statusItemWithLength(-1) statusItem.menu = mainMenu

Right-click on a NSStatusItem

半城伤御伤魂 提交于 2020-02-03 11:01:50
问题 I have a NSStatusItem and I want to popup a menu by rightclicking the item. I subclassed a NSView and overwrote the - (void)rightMouseDown:(NSEvent *)event method. I also implemented - (void)mouseDown:(NSEvent *)event for looking at the modifierflags. My problem is, that the view does not recieve the NSRightMouseDown -Event. And I don't know why? Any ideas how to get this event? Naturally I added the custom view to the statusitem. - UPDATE - Additional information: I have added a NSImageView

NSStatusItem fullscreen issues

自闭症网瘾萝莉.ら 提交于 2020-01-01 12:00:06
问题 I'm making a statusbar app that displays an NSPopover when the NSStatusItem is clicked, like this: I have added the ability to resize the popover by dragging on the edges, by subclassing the popover's view like this: class CMView: NSView { let tolerance : CGFloat = 10 var state = false override func mouseDown(theEvent: NSEvent) { let point = self.convertPoint(theEvent.locationInWindow, fromView: nil) if (point.y <= tolerance) { state = true } } override func mouseDragged(theEvent: NSEvent) {

What is alternative to NSStatusItem.popUpMenu?

痞子三分冷 提交于 2020-01-01 09:48:53
问题 NSStatusItem.popUpMenu has been deprecated in macOS 10.14, but I can't find a nice alternative. let m = statusItem.menu! statusItem.popUpMenu(m) // deprecated I tried direct pop-up using menu and the button, but it doesn't position properly. let m1 = m.items.first! m.popUp(positioning: m1, at: .zero, in: statusItem.button!) 回答1: Xcode suggests to use menu property instead of popupMenu . But once you set the menu property, every click on the item will only show the menu. Instead, if you want

Main Thread Runloop gets blocked on opening nsmenu

筅森魡賤 提交于 2019-12-31 01:41:27
问题 I have an application for which the UI element includes an NSStatusItem and a menu. Inside my application , I am using NSTask asynchronously to perform some operation and I am using the output obtained using the NSFileHandleReadCompletionNotification to update the menu. But now whenever I click and open the menu , the main runloop goes into NSEventTrackingRunLoopMode and the notification posting fails. So basically with my menu open , no operation takes place on the main thread. Now I found a

NSStatusBarButton keep highlighted

假装没事ソ 提交于 2019-12-29 06:09:47
问题 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

NSStatusBarButton keep highlighted

我们两清 提交于 2019-12-29 06:07:24
问题 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

NSStatusBarButton keep highlighted

房东的猫 提交于 2019-12-29 06:07:22
问题 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