typedef CALLBACK_API( Boolean , EventComparatorProcPtr ) typedef STACK_UPP_TYPE(EventComparatorProcPtr) EventComparatorUPP;(EventRef inEvent, void *inCompareData);
Type of a callback function used by queue searches.
Result: A boolean value indicating whether the event matches (true) or not (false).
Name Description inEvent The event to compare. inCompareData The data used to compare the event.
typedef CALLBACK_API( OSStatus , EventHandlerProcPtr ) typedef STACK_UPP_TYPE(EventHandlerProcPtr) EventHandlerUPP;(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
Callback for receiving events sent to a target this callback is
installed on.
Result: An operating system result code. Returning noErr indicates you handled the event. Returning eventNotHandledErr indicates you did not handle the event and perhaps the toolbox should take other action.
Name Description inHandlerCallRef A reference to the current handler call chain. This is sent to your handler so that you can call CallNextEventHandler if you need to. inEvent The Event. inUserData The app-specified data you passed in a call to InstallEventHandler.
typedef struct OpaqueEventLoopRef* EventLoopRef;
An EventLoopRef represents an 'event loop', which is the conceptual
entity that you 'run' to fetch events from hardware and other sources
and also fires timers that might be installed with InstallEventLoopTimer.
The term 'run' is a bit of a misnomer, as the event loop's goal is to
stay as blocked as possible to minimize CPU usage for the current
application.
The event loop is run implicitly thru APIs like ReceiveNextEvent,
RunApplicationEventLoop, or even WaitNextEvent. It can also be run
explicitly thru a call to RunCurrentEventLoop.
Each preemptive thread can have an event loop. Cooperative threads share
the main thread's event loop.
typedef struct OpaqueEventLoopTimerRef* EventLoopTimerRef;
An EventLoopTimerRef represents what we term a 'timer'. A timer is
a function that is called either once or at regular intervals. It
executes at task level and should not be confused with Time Manager
Tasks or any other interrupt-level callback. This means you can
call Toolbox routines, allocate memory and draw. When a timer 'fires',
it calls a callback that you specify when the timer is installed.
Timers in general have two uses - as a timeout mechanism and as a
periodic task. An everyday example of using a timer for a timeout
might be a light that goes out if no motion is detected in a room
for 5 minutes. For this, you might install a timer which will
fire in 5 minutes. If motion is detected, you would reset the
timer fire time and let the clock start over. If no motion is
detected for the full 5 minutes, the timer will fire and you could
power off the light.
A periodic timer is one that fires at regular intervals (say every
second or so). You might use such a timer to blink the insertion
point in your editor, etc.
One advantage of timers is that you can install the timer right
from the code that wants the time. For example, the standard
Toolbox Edit Text control can install a timer to blink the cursor
when it's active, meaning that IdleControls is a no-op for that
control and doesn't need to be called. When the control is inactive,
it removes its timer and doesn't waste CPU time in that state.
NOTE: Currently, if you do decide to draw when your timer is called,
be sure to save and restore the current port so that calling your
timer doesn't inadvertently change the port out from under someone.
typedef CALLBACK_API( void , EventLoopTimerProcPtr ) typedef STACK_UPP_TYPE(EventLoopTimerProcPtr) EventLoopTimerUPP;(EventLoopTimerRef inTimer, void *inUserData);
Called when a timer fires.
Name Description inTimer The timer that fired. inUserData The data passed into InstallEventLoopTimer.
© 2000 Apple Computer, Inc. (Last Updated 7/7/2000)