English 中文(简体)
处理返回密钥事件和自定义NSView
原标题:Handling Return key event and Custom NSView

我在mac应用程序中有一个自定义的NSView,我想在按下Return键时执行操作。

我的第一次尝试是查找此键的NSResponder操作消息(如-complet:用于ESC键)。看起来是–insertNewline:但它不适用于NSView。

第二个,override-keydown:并检查事件的keyCode。有效,但我注意到键Code只是键在键盘中的位置,不同的键盘(型号和语言)将为return键返回不同的键代码(正确吗?)。

最后一个是将我的视图子类化为NSControl,并在子类的-awakeFromNib方法中将选择器设置为perfom-action(同时设置目标)。

任何一个都有效。知道吗?

提前感谢

最佳回答

最后,insertNewline:效果完美。问题是,我使用“if”和“-inintersetKeyEvents:”覆盖keydown(当条件不允许执行insertNewline时,混合不好)。。。

问题回答

暂无回答




相关问题
Listen for Events from Browser "Find" Window in JavaScript

Is there a way to listen for typing into the browser s "find" window in JavaScript? (source: apple.com) I d like to be able to reinterpret the search text from JavaScript. What do I need to ...

Equivalent of PreviewKeyDown of C# needed for native C++/MFC

I used a ActiveXControl in a C# Forms application and had the possibility to implement a PreviewKeyDown event handler for that ActiveXControl. That was needed to specify that, e.g. the [ALT] key, is ...

Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to remove "onclick" with JQuery?

PHP code: <a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> I want to remove the onclick="check($id,1) so the link cannot be clicked or "check($id,...

热门标签