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 / Event Manager Reference
Event Manager Routines / Sending Events


PostEvent

The Toolbox Event Manager uses the PostEvent function to post events into the Operating System event queue. In most cases your application should not call the PostEvent function.

FUNCTION PostEvent (eventNum: Integer; eventMsg: LongInt): OSErr;
eventNum
A value that indicates the type of event to post into the Operating System event queue. The types of events that can be posted in this queue are represented by these constants: mouseDown, mouseUp, keyDown, keyUp, autoKey, and diskEvt. Do not attempt to post any other type of event in the Operating System event queue.
eventMsg
A long integer that contains the contents of the message field for the event that PostEvent should post in the queue.
DESCRIPTION
In the eventNum and eventMsg parameters, you specify the value for the what and message fields of the event's event record. The PostEvent function fills out the when, where, and modifiers fields of the event record with the current time, current mouse location, and current state of the modifier keys and mouse button.

The PostEvent function posts only events that are enabled by the system event mask. If the event queue is full, PostEvent removes the oldest event in the queue and posts the new event.

Note that if you use PostEvent to repost an event, the PostEvent function fills out the when, where, and modifier fields of the event record, giving these fields of the reposted event different values from the values contained in the original event.

WARNING
Do not post any events other than mouse-down, mouse-up, key-down, key-up, auto-key, and disk-inserted events in the Operating System event queue. Attempting to post other events into the Operating
System event queue interferes with the internal operation of the
Event Manager.
ASSEMBLY-LANGUAGE INFORMATION
You must set up register A0 with the event code and register D0 with the event
message before invoking PostEvent. When PostEvent returns, register D0
contains the result code.
Registers on entry
A0Event number (low-order word)
D0Event message (long)
Registers on exit
D0Result code (low-order word)

RESULT CODES
evtNotEnb1Event type not valid--event not posted
noErr0No error

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996