Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 2 - Event Manager / Event Manager Reference
Data Structures


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. The EventRecord 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 typeEvent message
 null, mouse-up, mouse-downUndefined.
 key-up, key-down, auto-keyCharacter 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, activatePointer to the window to update, activate, or deactivate.
 disk-insertedDrive number in low-order word, File Manager result code in high-order word.
 resumeThe 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.
 suspendThe 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-movedThe mouseMovedMessage constant in bits 24-31. Bits 2-23 are reserved, and bit 0 and bit 1 are undefined.
 high-levelClass 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.
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 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.
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 the modifiers 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 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.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice