nsmenu

NSMenuItem with custom view disappears while scrolling

五迷三道 提交于 2021-01-29 07:27:11
问题 I implement a NSMenu with NSMenuItem and set custom view to it. When menu is scrollable, mouse hovering on ▼ button to scroll will cause some menuItem disappear (or not draw correctly). Hope someone give me some help. I will appreciate that. Here's video about this issue: https://streamable.com/obrbon Here's my code: private func setupMenuItemView(_ menu: NSMenu) { let menuItemHeight: CGFloat = 20 let menuWidth = frame.width let textFieldPadding: CGFloat = 10 for menuItem in menu.items {

Stop Mouse Events from queueing while NSMenu is shown

荒凉一梦 提交于 2021-01-28 02:11:24
问题 I have several NSViews that trigger re-draws during the mouseEntered and mouseExited methods. When showing an NSMenu in the same window, updating of those NSViews is suspended (they don't get the mouseEntered and Exited events). My problem is that once the NSMenu is closed (after moving the mouse all over the window outside of the NSMenu), every mouseEntered and Exited event that would have been triggered immediately trigger in a fast sequence. So basically they were queueing up and then

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

纵然是瞬间 提交于 2021-01-21 04:08:08
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

↘锁芯ラ 提交于 2021-01-21 04:07:07
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

Swift: NSStatusItem menu behaviour in 10.10 (e.g. show only on right mouse click)

孤人 提交于 2021-01-21 04:06:26
问题 I am writing a simple status bar app in Swift, and attempting to use the new NSStatusItem API introduced in OS X 10.10. The interface I'm aiming for is a simple left mouse click on the statusItem to toggle a core feature on and off, with a right mouse click (or control-click) option to show a settings menu. I have no need for a custom view or popover for this functionality. By default, if a NSMenu is assigned to a NSStatusItem, it will display the menu on both a left and right click. I want

validateMenuItem or menuWillOpen not called for NSMenu

早过忘川 提交于 2020-12-06 07:27:47
问题 My Mac app has an NSMenu whose delegate functions validateMenuItem and menuWillOpen are never called. So far none of the solutions online have helped. It seems like I'm doing everything right: The menu item's selectors are in the same class. The class managing it inherits from NSMenuDelegate I suppose the best way to describe my problem is to post the relevant code. Any help would be appreciated. import Cocoa class UIManager: NSObject, NSMenuDelegate { var statusBarItem = NSStatusBar.system()