Next Page > Hide TOC

Introduction

Contents:

Organization of This Document
See Also


A primary responsibility of an event-driven application is to handle user events—that is, events generated by devices such as mice, keyboards, and tablets. For most Cocoa applications, the Application Kit assumes the largest share of this work. It ensures that events generated by the mouse, keyboard, and other devices are routed to the objects best suited to handle them. It also implements dozens of user-interface objects such as controls and text views to respond to events in expected ways—for example, by inserting typed text or sending an action message. But often an application, especially an application with custom NSView, NSWindow, or NSApplication objects, finds that it must handle some events itself.

Cocoa Event Handling Guide explains how to handle events of all types in a Cocoa application. It provides conceptual background for the task-based chapters by describing the Cocoa architecture for dispatching and handling events, and by giving an overview of NSEvent objects, which all event-handling code must deal with. Reading this document will give you a solid foundation for handling events in your Cocoa application. It is recommended that you read Cocoa Fundamentals Guide before reading this document.

Important: This is a preliminary version of this document. Although it has been reviewed for technical accuracy, it is not final. Other chapters may be added and current chapters may be updated and expanded.

Organization of This Document

This document includes the following chapters:

The appendix “Using Tracking-Area Objects” covers the legacy API for mouse tracking and cursor updates. It explains how to set up tracking and cursor rectangles and handle the events that are subsequently generated when users move the mouse cursor into those areas.

See Also

The following ADC Reference Library documents are conceptually related to Cocoa Event-Handling Guide:

Because view objects often redraw themselves in response to events, it is also recommended that you peruse Cocoa Drawing Guide.

The following sample code projects in the ADC Reference Library include illustrative event-handling code:

The following sample code projects, which are installed in /Developer/Examples/AppKit, also contain useful event-handling code:



Next Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.