Determine if NSMenu is Open

I have an NSMenu that opens when the user clicks NSStatusItem in the status bar. How to determine if NSMenu is open (extended) or not?

Thanks!

+4
source share
1 answer

You can use the NSMenuDelegate protocol to process menuWillOpen and menuWillClose . Use menuWillOpen to set a boolean indicating that the menu is open, and menuWillClose to disable it.


Update: It seems that menuWillClose: no longer an available delegation method. Use menuDidClose: .

+9
source

Source: https://habr.com/ru/post/1334691/


All Articles