开发者

Hotkeys? Key events?

开发者 https://www.devze.com 2022-12-13 19:52 出处:网络
I\'m trying to make a window open when the user 开发者_运维知识库pressed Cmd + L but how can I make my controller object listen to that particular key combination?Create a menu item, set its shortcut

I'm trying to make a window open when the user 开发者_运维知识库pressed Cmd + L but how can I make my controller object listen to that particular key combination?


Create a menu item, set its shortcut to Cmd-L, and connect it to an action on that controller (or on another controller, which forwards to your desired controller).

Or ... read the Handling Key Events section of the Cocoa Event-Handling Guide and implement a custom view that, when it is the first responder, interprets this key event and notifies your controller.

Or ... insert your controller into the responder chain.

... but the easiest method is the first I mentioned.

0

精彩评论

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

关注公众号