How to add NSViewController to a responder chain?

Eugene Gordin picture Eugene Gordin · Nov 19, 2013 · Viewed 8.3k times · Source

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!

Answer

Michael Dautermann picture Michael Dautermann · Nov 19, 2013

There's a nice tutorial found at CocoaWithLove.com.

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.