开发者

Determine whether an NSMenu is opened

开发者 https://www.devze.com 2023-02-02 21:21 出处:网络
I have an NSMenu w开发者_高级运维hich opens when a user clicks an NSStatusItem in the status bar. How can I determine if the NSMenu is opened (expanded) or not?

I have an NSMenu w开发者_高级运维hich 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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消