问题描述
我很难理解并找到有关如何使NSViewController接受键和鼠标事件的信息.我在某处读到要在NSViewController中注册这些事件,应将其添加到响应者链中,但是我找不到如何正确执行此操作的答案.
I'm having hard time understanding and finding info about how to make NSViewController accept key and mouse events. I read somewhere that in order to register these events in NSViewController it should be added to a responder chain, but I can't find the answer how to properly do this.
任何帮助都将受到高度赞赏!
Any kind of help is highly appreciated!
推荐答案
有一个不错的可在CocoaWithLove.com 找到的教程.
There's a nice tutorial found at CocoaWithLove.com.
总结:您将创建NSView的子类(例如"EugeneView"),然后该子类中将包含一些额外的方法,例如"setNextResponder
"和"setViewController
".并且执行这两种方法应该可以将您的NSViewController集成到响应者链中.
Summed up: you'll create a subclass of NSView (e.g. "EugeneView") and then that subclass will have some extra methods in it, such as "setNextResponder
" and "setViewController
". And doing these two methods should get your NSViewController integrated into the responder chain.
这篇关于如何将NSViewController添加到响应者链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!