nsmenuitem

NSMenuItem KeyEquivalent “ ”(space) bug

丶灬走出姿态 提交于 2020-06-25 09:08:13
问题 I want to set key equivalent " "(space) without any modifiers for NSMenuItem (in App Main Menu). As follows from documentation: For example, in an application that plays media, the Play command may be mapped to just “ ” (space), without the command key. You can do this with the following code: [menuItem setKeyEquivalent:@" "]; [menuItem setKeyEquivalentModifierMask:0]; Key Equivalent sets successfully, but it don't work. When I press "Space" key without modifiers nothing happens, but it's

NSApplication responder chain for arrow keys

℡╲_俬逩灬. 提交于 2020-05-24 05:33:08
问题 I have an NSTextField in my window and 4 menu items with key equivalents ← ↑ → ↓ . When the text field is selected and I press an arrow key, I would expect the cursor to move in the text field but instead the corresponding menu item action is performed. So there has to be an issue in the responder chain. To figure out what's wrong I've watched WWDC 2010 Session 145 – Key Event Handling in Cocoa Applications mentioned in this NSMenuItem KeyEquivalent space " " bug thread. The event flow for

How to use the MacOS app dock menu to re-open the app that has been closed (by using the red button located on the top left corner)?

陌路散爱 提交于 2020-04-30 11:08:25
问题 Good Day, When I close my MacOS app by using the red button (located at the top left corner), the MacOS application disapears but the dock icon is still there at the bottom. If I click right on the dock icon I want to add a "Re-Open" menu item to re-open the app. Below is the code produced to a certain point... When I click on "Re-Open" it prints "XXX" in the console... because I have not found the code to re-open the app! Any help would be much appreciated to fill up the below function call

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

menu item is enabled, but still grayed out

青春壹個敷衍的年華 提交于 2020-04-08 02:51:37
问题 I have a menu with several items created in interface builder. It looks fine there and 'enabled' is checked. But when I run application, all menu items are grayed out. I've checked isEnabled , it returns true. Also, menu items created programmatically (with initWithTitle and without interface builder) work just fine. Am I missing something here? I'm really quite new to OSX development (in fact, this is my first day). Thank you 回答1: Remember to set your menu item's target and ensure that said