且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拦截NSMenu键事件

更新时间:2023-12-04 14:02:04

KeyEquivalent用于不拦截所有键的菜单快捷方式.无需拦截NSMenu事件,并且无法将其用于此目的.要创建一个建议框,您基本上需要创建一个自定义NSWindow并使它看起来像菜单.

KeyEquivalent is for menu shortcuts not intercepting all the keys. There is no need to intercept the NSMenu events and it is not possible to be used for that purpose. To make a suggestion box you basically need to make a custom NSWindow and make it look like a menu.

Apple提供了示例代码,他们解释了有时它会在 WWDC 2010会议145 中出现.

Apple provides a Sample Code and they explained it in WWDC 2010 session 145 at some point.