Hotkeys? Key events?

心不动则不痛 提交于 2019-12-06 14:14:04

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1876086/hotkeys-key-events

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