Important: The information in this document is obsolete and should not be used for new development.
The Event Record
When your application uses an Event Manager routine to retrieve an event, the Event Manager returns information about the retrieved event in an event record. TheEventRecord
data type defines the event record.
TYPE EventRecord = RECORD what: Integer; {event code} message: LongInt; {event message} when: LongInt; {ticks since startup} where: Point; {mouse location} modifiers: Integer; {modifier flags} END;
Field Description
what
- The
what
field indicates the type of event received. The type of event can be identified by these constants:CONST nullEvent = 0; {no other pending events} mouseDown = 1; {mouse button pressed} mouseUp = 2; {mouse button released} keyDown = 3; {key pressed} keyUp = 4; {key released} autoKey = 5; {key repeatedly held down} updateEvt = 6; {window needs updating} diskEvt = 7; {disk inserted} activateEvt = 8; {activate/deactivate window} osEvt = 15;{operating-system event-- } { resume, suspend, or } { mouse-moved} kHighLevelEvent = 23;{high-level event}
- Note that in System 7, event types with the values 9 through 14 are undefined and reserved for future use by Apple. All other values for the
what
field are also reserved for use by Apple.message
- 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:
Event type Event message null, mouse-up, mouse-down Undefined. key-up, key-down, auto-key Character code and virtual key code in low-order word. 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. update, activate Pointer to the window to update, activate, or deactivate. disk-inserted Drive number in low-order word, File Manager result code in high-order word. resume The suspendResumeMessage
constant in bits 24-31 and a 1 in bit 0 to indicate the event is a resume event. Bit 1 contains either a 1 or a 0 to indicate if Clipboard conversion is required, and bits 2-23 are reserved.suspend The suspendResumeMessage
constant in bits 24-31 and a 0 in bit 0 to indicate the event is a suspend event. Bit 1 is undefined, and bits 2-23 are reserved.mouse-moved The mouseMovedMessage
constant in bits 24-31. Bits 2-23 are reserved, and bit 0 and bit 1 are undefined.high-level Class of events to which the high-level event belongs. The message
andwhere
fields of
a high-level event define the specific type of high-level event received.when
- The
when
field indicates the time when the event was posted (in ticks since system startup).where
- 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 themessage
field of the high-level event. For high-level events, you should interpret thewhere
field as having the data typeOSType
, notPoint
.modifiers
- 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 record. Figure 2-5, on page 2-20, shows how to interpret themodifiers
field. 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 themodifiers
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.