Event Handling in Custom NSView Subclasses

The NSView class is a subclass of NSResponder. This means that any instance of NSView, or one of its subclasses, can be a part of the responder chain and potentially can become the first responder. As described in Chapter 8, the Application Kit automatically sends pertinent events to view instances. An event enters through the application object, which then distributes it to the appropriate window. The window passes the event to the appropriate view object. The type of the event and the state of the application determine the appropriate window and view. To receive events, an NSView subclass simply has to override the appropriate NSResponder method(s), such as -mouseDown: or -keyDown:.

This section doesn’t ...

Get Cocoa® Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.