NSMenu 打开时捕获按键事件

发布于 2024-09-24 12:54:41 字数 281 浏览 0 评论 0原文

我对在 NSMenu 打开时捕获按键感兴趣。例如,如果菜单打开并且用户按下键盘上的“e”或“1”,则发送特定消息(最好传递包含对按下哪个键的引用的事件对象)。

我研究过替代菜单,但我的印象是只能用于捕获选项键。

目前我没有使用任何自定义视图,只是使用 NSStatusBar (菜单从中生成)和 NSMenu

我是 Objective-C 的新手,所以如果我的措辞不正确,我深表歉意。

非常感谢您的帮助!

I'm interested in capturing key presses while a NSMenu is open. For example, if the menu is open and the user presses "e", or "1" on the keyboard, send a particular message (preferably passing an event object which contains reference to which key was pressed).

I've looked into alternate menus, but I'm under the impression that can only be used to capture the option key.

Currently I'm not using any custom views, just NSStatusBar (where the menu spawns from) and NSMenu.

I'm new to Objective-C so my apologies if I'm wording anything incorrectly.

Really appreciate the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾`听者〃 2024-10-01 12:54:41

我假设您正在寻找这个: Cocoa NSStatusBar Global HotKey

I assume you are searching for this: Cocoa NSStatusBar Global HotKey

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文