Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine whether an NSMenu is opened

I have an NSMenu which opens when a user clicks an NSStatusItem in the status bar. How can I determine if the NSMenu is opened (expanded) or not?

Thank you!

like image 320
Knodel Avatar asked Jan 07 '11 18:01

Knodel


1 Answers

You can use the NSMenuDelegate protocol to handle menuWillOpen and menuWillClose messages. Use menuWillOpen to set a boolean that states that the menu is open, and menuWillClose to turn it off.


Update: Looks like menuWillClose: is no longer an available delegate method. Use menuDidClose: instead.

like image 101
Itai Ferber Avatar answered Oct 22 '22 09:10

Itai Ferber