检测到OS X菜单栏上的单击? [英] Detect click on OS X menu bar?

查看:86
本文介绍了检测到OS X菜单栏上的单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇是否有一个技巧可以检测整个菜单栏上的单击.我知道我可以检测到对NSStatusItem或NSMenu的单击,但是我正在寻找与菜单栏的空白有关的事件.

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?

推荐答案

您可以使用NSEvent安装本地事件监视器addLocalMonitorForEventsMatchingMask:handler:

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

请参阅位于 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆