![]() |
EventRecord |
Header: Events.h |
struct EventRecord { EventKind what; UInt32 message; UInt32 when; Point where; EventModifiers modifiers; };
The kind of event received. The Event Manager specifies the kind of event with one of the values defined by the EventKind enumeration.
Additional information associated with the event. The interpretation of this information depends on the event type. The contents of the message field for each event type are summarized here:
Undefined.
The low-order word contains the character code and virtual key code, which you can access with the constants charCodeMask and keyCodeMask, respectively. For Apple Desktop Bus (ADB) keyboards, the low byte of the high-order word contains the ADB address of the keyboard where the keyboard event occurred. The high byte of the high-order word is reserved.
A pointer to the window to update, activate, or deactivate.
The drive number in the low-order word, the File Manager result code in the high-order word.
The suspendResumeMessage enumerator in bits 2431 and a 1 (the resumeFlag enumerator) in bit 0 indicate the event is a resume event. Bit 1 contains a 1 (the convertClipBoardFlag enumerator) if Clipboard conversion is required, and bits 223 are reserved.
The suspendResumeMessage enumerator in bits 2431 and a 0 in bit 0 to indicate the event is a suspend event. Bit 1 is undefined, and bits 223 are reserved.
The mouseMovedMessage enumerator in bits 2431. Bits 223 are reserved, and bit 0 and bit 1 are undefined.
The class of events to which the high-level event belongs. The message and where fields of a high-level event define the specific type of high-level event received.
The when field indicates the time when the event was posted (in ticks since system startup).
For low-level events and operating-system events, the where field contains the location of the cursor at the time the event was posted (in global coordinates).
For high-level events, the where field contains a second event specifier, the event ID. The event ID defines the particular type of event within the class of events defined by the message field of the high-level event. For high-level events, you should interpret the where field as having the data type OSType, not Point.
The modifiers field contains information about the state of the modifier keys and the mouse button at the time the event was posted. For activate events, this field also indicates whether the window should be activated or deactivated. In System 7 it also indicates whether the mouse-down event caused your application to switch to the foreground.
Each of the modifier keys is represented by a specific bit in the modifiers field of the event structure. The modifier keys include the Option, Command, Caps Lock, Control, and Shift keys. If your application attaches special meaning to any of these keys in combination with other keys or when the mouse button is down, you can test the state of the modifiers field to determine the action your application should take. For example, you can use this information to determine whether the user pressed the Command key and another key to make a menu choice.
When your application uses an Event Manager function to retrieve an event, the Event Manager returns information about the retrieved event in an event structure, which is a structure of type EventRecord.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)