Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dont hide NSMenu after click [closed]

Tags:

macos

cocoa

Have a way to I block hide the NSMenu after click.

Thanks.

like image 279
rafa Avatar asked Oct 15 '25 15:10

rafa


2 Answers

No, I've written several menubar apps and I've found the only way to disable menu-closing is to subclass NSMenuItem and do your own event handling. Unfortunately that also means you have to use a custom view, do your own title drawing, menu highlighting and "flash" animation.

like image 74
Francis McGrew Avatar answered Oct 18 '25 06:10

Francis McGrew


Another option is to switch to a view based menu item. Then in your view class, respond to - (void) mouseUp:(NSEvent*) event and implement your custom behavior. The menu will not close on the click, as the event is no longer forwarded up the responder chain to the menu item.

like image 25
NSSplendid Avatar answered Oct 18 '25 06:10

NSSplendid