Handling Events in Windows

As described in NSResponder Class Reference, most events coming into an application make their way to a window in a sendEvent: message. A key event is directed at the key window, while a mouse event is directed at whatever window lies under the pointer. If an event affects the window directly—resizing or moving it, for example—it performs the appropriate operation itself and sends messages to its delegate informing it of its intentions, thus allowing your application to intercede. The window sends other events up its responder chain from the appropriate starting point: the first responder for a key event, the view under the pointer for a mouse event. These events are then typically handled by some view object in the window. See Cocoa Event Handling Guide for more information on how to intercept and handle events.