Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /


Chapter 2 - Event Manager

This chapter describes how your application can use the Toolbox Event Manager to receive information about actions performed by the user, to receive notice of changes in the processing status of your application, and to communicate with other applications.

For example, you can retrieve information from the Toolbox Event Manager that gives your application details about whether the user has pressed a key or the mouse button, whether one of your application's windows needs updating, or whether some other hardware-related or software-related action requires a response from your application.

Your application also uses the Event Manager to support the cooperative, multitasking environment available on Macintosh computers. This environment allows users to switch between many open applications and allows other applications to receive background processing time. By using Event Manager routines, you allow the system software to coordinate the scheduling of processing time between your application and other applications.

The Event Manager and Process Manager maintain the cooperative, multitasking environment. The Process Manager coordinates the scheduling of applications, and the Event Manager communicates information about changes in your application's processing status to your application.

See the chapter "Process Manager" in Inside Macintosh: Processes for complete information on how the Process Manager schedules applications for execution.

You can use the Event Manager to communicate with other applications. Your application can also communicate with other applications using the services of the Apple Event Manager.

The Event Manager and Apple Event Manager routines that let your application communicate with other applications depend on the services of the Program-to-Program Communications (PPC) Toolbox. The services performed by the Event Manager and Apple Event Manager meet the needs of most applications for interapplication communication. However, to get additional control or capabilities not provided by the Event Manager or Apple Event Manager, you can choose to access the PPC Toolbox directly. The chapter "Program-to-Program Communications Toolbox" in Inside Macintosh: Interapplication Communication describes the PPC Toolbox routines that are available to your application.

For a comparison of the services provided by the Event Manager, Apple Event Manager, and PPC Toolbox, see Inside Macintosh: Interapplication Communication. For additional information about Apple events, including descriptions of how to process the required Apple events, see Inside Macintosh: Interapplication Communication.

This chapter describes both the Toolbox Event Manager and the Operating System Event Manager. The Operating System Event Manager maintains a queue in which it stores hardware-related occurrences that you may want your application to respond to. The Toolbox Event Manager communicates the information maintained by the Operating System Event Manager to your application. In most cases, your application needs to interact only with the Toolbox Event Manager. In this chapter, the name Event Manager refers to the Toolbox Event Manager.

This chapter provides a general introduction to events and then explains how you can use the Event Manager to


Chapter Contents
Introduction to Events
Low-Level Events
Operating-System Events
High-Level Events
Priority of Events
Switching Contexts
About the Event Manager
Using the Event Manager
Obtaining Information About Events
Processing Events
Using the WaitNextEvent Function
Writing an Event Loop
Setting the Event Mask
Handling Events in a Dialog Box
Creating a Size Resource
Handling Low-Level Events
Responding to Mouse Events
Responding to Keyboard Events
Scanning for a Cancel Event
Responding to Update Events
Responding to Activate Events
Responding to Disk-Inserted Events
Responding to Null Events
Handling Operating-System Events
Responding to Suspend and Resume Events
Responding to Mouse-Moved Events
Handling High-Level Events
Responding to Events From Other Applications
Searching for a Specific High-Level Event
Determining the Sender of a High-Level Event
Sending High-Level Events
Requesting Return Receipts
Handling Apple Events
Event Manager Reference
Data Structures
The Event Record
The Target ID Record
The High-Level Event Message Record
The Event Queue
Event Manager Routines
Receiving Events
Sending Events
Converting Process Serial Numbers and Port Names
Reading the Mouse
Reading the Keyboard
Getting Timing Information
Application-Defined Routine
Filter Function for Searching the High-Level Event Queue
Resource
The Size Resource
Summary of the Event Manager
Pascal Summary
Constants
Data Types
Event Manager Routines
Application-Defined Routine
C Summary
Constants
Data Types
Event Manager Routines
Application-Defined Routine
Assembly-Language Summary
Data Structures
Trap Macros
Global Variables
Result Codes

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996