Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMenuItem Key Equivalent not working when menu is hidden

I have an NSMenu in Interface Builder that is connected to an NSTableView's menu outlet.

I want to assign Key Equivalents to the items in this menu so the user doesn't have to right click, but they don't work unless the menu is visible (defeating the point).

Is there any way to allow the key equivalent to work when the menu is not visible?

like image 844
colincameron Avatar asked Nov 30 '12 12:11

colincameron


2 Answers

You can put the menu items in both, the application's menubar and the context menu. The key equivalent will then work even without the context menu being visible.

like image 114
Matthias Avatar answered Oct 06 '22 12:10

Matthias


Looks like the macOS 10.13 SDK (High Sierra) has a new property allowsKeyEquivalentWhenHidden on NSMenuItem.

like image 20
Frederik Avatar answered Oct 06 '22 12:10

Frederik