Detect click on OS X menu bar?

一曲冷凌霜 提交于 2019-12-23 00:51:31

问题


I'm curious if there's a trick to detecting a click on the Menu Bar as a whole. I know I can detect a click on an NSStatusItem or NSMenu, but I am looking for events pertaining to the empty space of the Menu Bar.

Looking through the documentation, it does not seem possible. However, I wanted to know if anyone had a workaround for this functionality?


回答1:


You can install a local event monitor using NSEvent addLocalMonitorForEventsMatchingMask:handler:

See the documentation located here.



来源:https://stackoverflow.com/questions/7249239/detect-click-on-os-x-menu-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!