TweetFollow Us on Twitter

MACINTOSH C CARBON
MACINTOSH C CARBON: A Hobbyist's Guide To Programming the Macintosh in C
Version 1.0
© 2001 K. J. Bricknell
Go to Contents Go to Program Listing

CHAPTER 17

THE CARBON EVENT MODEL

Overview

The Carbon Event Model

The Carbon event model, which was introduced with Carbon as an alternative to what is now termed the Classic event model, reduces the amount of events-related code required by an application and, in addition, facilitates a more efficient allocation of processing time on the preemptive multitasking Mac OS X. Indeed, the Carbon event model is the underlying event model on Mac OS X, the Classic event model being constructed on top of this model and emulated by the Carbon Event Manager.

Event Handling Basics

As will by now be apparent, applications using the Classic event model spend a large amount of time in the WaitNextEvent loop handling such user-interface events as mouse-downs and key-downs. In the Carbon event model, this continual and inefficient "polling" for events is avoided, events being dispatched directly to Toolbox objects.

Standard Event Handlers

These dispatched events may be handled automatically by standard event handlers provided by the Carbon Event Manager if you so specify. The provision of standard event handlers greatly simplifies the programming task. As an example, and as will be seen in the demonstration program CarbonEvents1, your application requires no code at all to handle basic window dragging, resizing, zooming, activation, and deactivation operations.

Standard event handlers are provided for each type of event target (windows, menus, controls, and the application itself).

Overriding and Complementing the Standard Handlers

At the same time, you can override or complement the default behavior provided by the standard event handlers by writing your own handlers and installing them on the relevant objects. Your application's event handler will override the standard event handler if it returns noErr, which defeats the event being passed to the standard handler. Your application's event handler will complement the standard event handler if it returns eventNotHandledErr, which causes the event to be further propagated to the standard event handler following handling by your application's event handler. (Event handlers are installed on a stack, the most recently installed on top. The most recently installed handler is called first.)

The Basic Approach

The basic approach to using the Carbon event model API is thus to install the relevant standard event handlers first and then register the types of events your application wishes to receive in order to override or complement the actions of the standard handlers.

Event Propagation Order

Events are propagated in a particular order, that order depending on the type of event. For example, control-related events are sent first to the control, then to the owning window, and then to the application. This means that you can install a handler for the control on either the control, the owning window (as in the demonstration program CarbonEvents1), or the application.

As another example, menu-related events are sent first to the menu, then to the user focus target (that is, the object with current keyboard focus, which can be either a window or a control), then to the application.

RunApplicationEventLoop

At the point where a Classic event model version of your application would call WaitNextEvent, your Carbon event model application calls the Carbon Event Manager function RunApplicationEventLoop. RunApplicationEventLoop:

  • Moves events from lower-level OS queues into the Carbon queue.
  • Dispatches those events from the Carbon queue to the standard event handlers and, for events types that your application has registered, to your application's event handlers.

When an event occurs that requires your program's attention, the Carbon Event Manager calls the handler for that event type. On return from the handler, your program is suspended until the next event requiring its attention is received. Thus your program only uses processor time when processing an event, other programs and processes running in the meantime.

Event Timers

The Carbon Event Manager supports the installation of timers, which can be set to fire either once or repeatedly, and which may be used to trigger calls to a specified function at a specified elapsed time or at specified intervals.

Event Reference, Class, and Type

Event Reference

The event reference is the core Carbon Event Manager data structure:

     typedef struct OpaqueEventRef *EventRef;

Event Class and Type

As was stated at Chapter 2, the Classic event model is limited to a maximum of 16 event types. By contrast, the Carbon event model can accommodate an unlimited number of event types. Event types are grouped by event class.

Typical event classes, as represented by constants in CarbonEvents.h, are as follows:

     kEventClassApplication
     kEventClassWindow
     kEventClassControl
     kEventClassMenu

Each event class comprises a number of event types. For example, some of the many event types pertaining to the kEventClassWindow event class, as represented by constants in CarbonEvents.h, are as follows:

     kEventWindowDrawContent
     kEventWindowActivated
     kEventWindowClickDragRgn
     kEventWindowGetIdealSize

Given an event reference, your application can ascertain the class and type of a received event by calling GetEventClass and GetEventKind.

Standard Event Handlers

Standard Application Event Handler

The standard application event handler is installed automatically when your application calls RunApplicationEventLoop. Amongst other things, the standard application event handler handles application-activated and application-deactivated events (in Classic event model parlance, resume and suspend events).

Standard Window Event Handler

The standard window event handler handles all of the possible user inter-actions with a window (dragging, resizing, zooming, activation, deactivation, etc.). It must be explicitly installed on the target window by your application. You can cause the standard window event handler to be installed on a window as follows:

  • For a window created from a 'WIND' resource using GetNewCWindow, either set the standard handler attribute in a call to the function ChangeWindowAttributes, for example:

         ChangeWindowAttributes(windowRef,kWindowStandardHandlerAttribute,0);
    
    or call InstallStandardEventHandler, passing in an event target reference (type EventTargetRef) obtained using GetWindowEventTarget, for example:
         InstallStandardEventHandler(GetWindowEventTarget(windowRef));
    

  • For a window created using CreateNewWindow, pass kWindowStandardHandlerAttribute in the attributes parameter.

The Application's Event Handlers

Handlers are Callback Functions

The handlers provided by your application are callback functions. When called, they are passed:

  • A reference to the event handler call (type EventHandlerCallRef).
  • The event reference, from which you can extract the event class and type.
  • A pointer to user data ( assuming that you passed a pointer to that data when you installed the handler).

Installing the Application's Event Handlers

You can install handlers provided by your application using InstallEventHandler:

OSStatus  InstallEventHandler(EventTargetRef inTarget,EventHandlerUPP inHandler,
                              UInt32 inNumTypes,const EventTypeSpec *inList,
                              void *inUserData,EventHandlerRef *outRef);

inTarget

An event target reference to the target the handler is to be registered with. Use one of the following functions to obtain this reference:

     GetApplicationEventTarget
     GetWindowEventTarget
     GetControlEventTarget
     GetMenuEventTarget
     GetUserFocusEventTarget
inHandler

A universal procedure pointer to the handler function provided by your application.

inNumTypes

The number of event types to be registered by this call to InstallEventHandler.

inList

A pointer to an array of type EventTypeSpec structures specifying the event types being registered. The EventTypeSpec structure is as follows:

     struct EventTypeSpec 
     {
       UInt32 eventClass;  // Event class
       UInt32 eventKind;   // Event type
     };
     typedef struct EventTypeSpec EventTypeSpec;

For example, if you wished to register the kEventWindowDrawContent and kEventWindowActivated event types, you would define the array as follows:

     EventTypeSpec myTypes[] = { { kEventClassWindow, kEventWindowDrawContent },
                                 { kEventClassWindow, kEventWindowActivated   } };
inUserData

Optionally, a pointer to data to be passed to your event handler when it is called.

outRef

If you will later need to remove the handler, pass a pointer to a variable of type EventHandlerRef in this parameter. On return, this variable will receive the event handler reference that will be required by your call to RemoveEventHandler.

You can also use the following macros, which are derived from the function InstallEventHandler, to install your application's handlers:

     InstallApplicationEventHandler
     InstallWindowEventHandler
     InstallControlEventHandler
     InstallMenuEventHandler

Different object of the same type do not have to have the same handler. For example, you can install separate handlers on each of two windows.

Inside The Application's Event Handlers

Getting Event Parameters

In some circumstances, in order to correctly handle a particular event type, you may need to extract specific data from the event using the function GetEventParameter. For example, on receipt of an event in the kEventClassWindow class, you will almost invariably need to call GetEventParameter to get the window reference required to facilitate the handling of certain event types in that class. Similarly, on receipt of an event of type kEventMouseDown, you might need to call GetEventParameter to obtain the mouse location.

The GetEventParameter prototype is as follows:

OSStatus  GetEventParameter(EventRef inEvent,EventParamName inName,
                            EventParamType inDesiredType,EventParamType *outActualType,
                            UInt32 inBufferSize,UInt32 *outActualSize,void *outData);

inEvent

A reference to the event.

inName

The parameter's symbolic name. Symbolic names pertaining to the various event types are listed in CarbonEvents.h immediately after the enumerations for those types. For example, the symbolic name for the mouse location is kEventParamMouseLocation.

inDesiredType

The type of data. This is listed against the parameter's symbolic name in CarbonEvents.h. For example, the type of data pertaining to the symbolic name kEventParamMouseLocation is typeQDPoint.

outActualType

Actual type of value returned. Specify NULL if this information is not needed.

inBufferSize

The size of the output buffer.

outActualSize

Actual size of value returned.Specify NULL if this information is not needed.

outData

A pointer to the buffer which will receive the parameter data.

The types of data that can be extracted from an event depends on the type of event. The parameter symbolic names and data types listed in CarbonEvents.h together indicate the type, or types, of data obtainable from an event of a particular type.

Event Parameters and Command Events

The Carbon Event Manager can associate special command events with menu items with command IDs. You can, of course, assign your own command IDs to menu items using SetMenuItemCommandID; however, note that CarbonEvents.h defines command IDs for many common menu items, for example:

     kHICommandQuit  = FOUR_CHAR_CODE('quit')
     kHICommandUndo  = FOUR_CHAR_CODE('undo')
     kHICommandCut   = FOUR_CHAR_CODE('cut ')
     kHICommandPaste = FOUR_CHAR_CODE('past')

When a menu item with a command ID is chosen by the user, either with the mouse or using a Command-key equivalent, the Carbon Event Manager dispatches the relevant command event (class kEventClassCommand, type kEventProcessCommand).

When your application's handler receives a kEventProcessCommand event type, you pass kEventParamDirectObject in the inName parameter of your GetEventParameter call, typeHICommand in the inDesiredType parameter, and the address of a structure of type HICommand in the outData parameter. The HICommand structure is as follows:

     struct HICommand 
     {
       UInt32 attributes;
       UInt32 commandID;
       struct 
       {
         MenuRef menuRef;
         UInt16  menuItemIndex;
       } menu;
     };
     typedef struct HICommand HICommand;

Thus you will be able to extract the menu reference and menu item number, as well as the command ID of the chosen menu item (if any), from the data returned by the call to GetEventParameter.

Quit Command Handling

The Quit command event is a special case. When the Quit item is chosen, the standard application event handler calls either the default Quit Application Apple event handler or your application's Quit Application Apple event handler if it has installed its own. (When your application calls RunApplicationEventLoop, the default Quit Application Apple event handler is automatically installed if the application has not installed its own.)

Thus the only action required by your application's handler is to ensure that it returns eventNotHandledErr when it determines that the commandID field of the HICommand structure contains kHICommandQuit, thereby causing the event to be propagated to the standard application event handler and thence to the relevant Quit Application Apple event handler.

For this to work on Mac OS 8/9, your application must assign the command ID kHICommandQuit to the Quit item at program start when the application determines that it is running on Mac OS 8/9.

Setting Event Parameters

In certain circumstances, your handler will need to call SetEventParameter to set a piece of data for a given event. For example, suppose you wish to constrain window resizing to a specified minimum size and, accordingly, register for the kEventWindowGetMinimumSize event type. When this event type is received by your handler (it will be dispatched when a mouse-down occurs in the size box/resize control of a window on which your handler is installed), your handler should call SetEventParameter with kEventParamDimensions passed in the inName parameter and a pointer to a variable of type Point passed in the inDataPtr parameter. (The Point variable should contain the desired minimum window height and width.)

Converting an Event Reference to an Event Record

In certain circumstances, your handler may need to convert the event reference to a Classic event model event structure (type EventRecord) in order to be able to handle the event. You can use the function ConvertEventRefToEventRecord for that purpose.

Menu Adjustment

You can ensure that your application's menu adjustment function is called when appropriate by registering the kEventMenuEnableItems event type (kEventClassMenu event class) and calling your menu adjustment function when that event type is received. The kEventMenuEnableItems event type will be dispatched when a mouse-down occurs in the menu bar and when a menu-related Command-key equivalent is pressed.

Cursor Shape Changing

In Classic event model applications, the application's cursor shape-changing function is typically called when mouse-moved Operating System events are received. An alternative "trigger" is required when using the Carbon event model.

One approach is to install a Carbon events timer set to fire at an appropriate interval and call the cursor shape-changing function when the timer fires. However, this method is not recommended for Mac OS X because it is somewhat like polling for an event, which is more processor-intensive.

The recommended approach is to register for the kEventMouseMoved event type (kEventClassMouse event class) and call the cursor shape-changing function on receipt of that event type.

Window Updating

To accommodate window content region updating (re-drawing) requirements, your application should register for the kEventWindowDrawContent event type (kEventClassWindow event class) and call its update function when that event type is received.

Note that the Window Manager sends an event of type kEventWindowUpdate to all windows that need updating, regardless of whether those windows have the standard window event handler installed or not. If the standard window event handler is installed, then when the standard handler receives the kEventWindowUpdate event, it calls BeginUpdate, sends a kEventWindowDrawContent event, and calls EndUpdate. There is thus no need for your update function to call BeginUpdate and EndUpdate when responding to kEventWindowDrawContent events.

Handler Disposal

All handlers on a target are automatically disposed of when the target is disposed of.

Sending and Explicitly Propagating Events

Sending Events

You can send an event to a specified event target using either the function SendEventToEventTarget or the following macros derived from that function:

     SendEventToApplication
     SendEventToWindow
     SendEventToControl
     SendEventToMenu
     SendEventToUserFocus

Explicitly Propagating Events

You can explicitly propagate an event up the propagation chain by calling CallNextEventHandler within your event handler. This is useful in circumstances where, for example, you wish to incorporate the standard handler's response into your own pre- or post-processing.

Event Timers

Event timers may be used for many purposes, the most common one being to trigger a call to your application's idle function, perhaps for the purpose of blinking the insertion point caret. You can use InstallEventLoopTimer to install an event timer:

OSStatus  InstallEventLoopTimer(EventLoopRef inEventLoop,EventTimerInterval inFireDelay,
                                EventTimerInterval inInterval,
                                EventLoopTimerUPP inTimerProc, void *inTimerData,
                                EventLoopTimerRef *outTimer);

inEventLoop

The event loop on which the timer is to be installed. Usually, this will be the event loop reference returned by a call to GetCurrentEventLoop.

inFireDelay

The required delay before the timer first fires. This can be 0.

inInterval

A value of type double specifying the interval at which the timer is required to fire. For one-shot timers, 0 should be passed in this parameter. For a timer whose purpose is to trigger calls to an idle function which blinks the insertion point caret, pass the value returned by a call to GetCaretTime converted to event time by the macro TicksToEventTime.

Note that event time is in seconds since system startup. You can use the macros TicksToEventTime and EventTimeToTicks to convert between ticks and event time.

inTimerProc

A universal procedure pointer to the function to be called when the timer fires.

inTimerData

Optionally, a pointer to data to be passed to the function called when the timer fires.

OutTimer

A reference to the newly-installed timer. Usually, this will be required only if you intend to remove the timer at some point.

Note that, depending on the parameters passed to this function, the timer can be set to fire either once or repeatedly at a specified interval.

You can remove an installed timer by calling RemoveEventLoopTimer.

Getting Event Time

Your application can determine the time an event occurred using the function GetEventTime. It can also determine the time from system startup using the function GetCurrentEventTime.

Other Aspects of the Carbon Event Model

The Carbon Event Model and Apple Events

Your application requires no code at all to ensure that, when Apple events are dispatched to it, its Apple event handlers are called.

Carbon Event Model and Control Hierarchies

When you establish an embedding hierarchy for controls, you are also establishing an event handling chain. When you click in a given control, the event is sent first to that control. If that control does not handle the event (that is, its handler returns eventNotHandledErr), the event is passed up the chain to the control that contains the first control, and so on up the chain.

Carbon Event Model and Event Filter Functions

In Classic event model applications, you must pass a universal procedure pointer to an application-defined event filter (callback) function in the modalFilter parameter of ModalDialog, and call your application's window updating function within the filter function.

Calling your window updating function from within your event filter function is not necessary in Carbon event model applications provided the application installs the standard window event handler on the relevant windows, registers for the kEventWindowDrawContent event type, and calls its window updating function when that event type is received.

Mouse Tracking

The demonstration program QuickDraw (Chapter 12) uses the Event Manager function StillDown in the doDrawWithMouse function to determine whether the mouse button has been continuously pressed since the most recent mouseDown event. The Event Manager function WaitMouseUp is often used for similar purposes.

For reasons of efficient use of processor cycles, TrackMouseLocation should be used in lieu of StillDown and WaitMouseUp in applications intended to run on Mac OS X. (TrackMouseLocation does not return control to your application until the mouse is moved or the mouse button is released.) When TrackMouseLocation returns, the outResult parameter contains a value representing the type of mouse activity that occurred (press, release, etc.) and the outPt parameter contains the mouse location.

The function TrackMouseRegion is similar to TrackMouseLocation except that TrackMouseRegion only returns when the mouse enters or exits a specified region.

Alternative for Delay Function on Mac OS X

Programs sometimes call the function Delay to pause program execution for the number of ticks passed in the duration parameter. On Mac OS X, if the delay is more than about two seconds, the cursor will automatically be set to the wait cursor. To avoid this, you can instead call the function RunCurrentEventLoop with the required delay in seconds (perhaps converted from ticks using the macro TicksToEventTime) passed in the inTimeout parameter.

Main Constants, Data Types, and Functions

Constants

Error Codes

eventAlreadyPostedErr           = -9860
eventClassInvalidErr            = -9862
eventClassIncorrectErr          = -9864
eventHandlerAlreadyInstalledErr = -9866
eventInternalErr                = -9868
eventKindIncorrectErr           = -9869
eventParameterNotFoundErr       = -9870
eventNotHandledErr              = -9874
eventLoopTimedOutErr            = -9875
eventLoopQuitErr                = -9876
eventNotInQueueErr              = -9877

Event Classes

kEventClassMouse                = FOUR_CHAR_CODE('mous')
kEventClassKeyboard             = FOUR_CHAR_CODE('keyb')
kEventClassTextInput            = FOUR_CHAR_CODE('text')
kEventClassApplication          = FOUR_CHAR_CODE('appl')
kEventClassMenu                 = FOUR_CHAR_CODE('menu')
kEventClassWindow               = FOUR_CHAR_CODE('wind')
kEventClassControl              = FOUR_CHAR_CODE('cntl')
kEventClassCommand              = FOUR_CHAR_CODE('cmds')

Event Types

kEventMouseDown                 = 1
kEventMouseUp                   = 2
kEventMouseMoved                = 5
kEventMouseDragged              = 6

kEventRawKeyDown                = 1
kEventRawKeyRepeat              = 2
kEventRawKeyUp                  = 3
kEventRawKeyModifiersChanged    = 4

kEventAppActivated              = 1
kEventAppDeactivated            = 2
kEventAppQuit                   = 3
kEventAppLaunchNotification     = 4

kEventMenuEnableItems           = 8

kEventWindowUpdate              = 1
kEventWindowDrawContent         = 2
kEventWindowActivated           = 5
kEventWindowDeactivated         = 6
kEventWindowGetClickActivation  = 7
kEventWindowShown               = 24
kEventWindowHidden              = 25
kEventWindowBoundsChanging      = 26
kEventWindowBoundsChanged       = 27
kEventWindowClickDragRgn        = 32
kEventWindowClickResizeRgn      = 33
kEventWindowClickCollapseRgn    = 34
kEventWindowClickCloseRgn       = 35
kEventWindowClickZoomRgn        = 36
kEventWindowClickContentRgn     = 37
kEventWindowClickProxyIconRgn   = 38

kEventControlHit

kEventProcessCommand            = 1

HI Commands

kHICommandOK                    = FOUR_CHAR_CODE('ok  ')
kHICommandQuit                  = FOUR_CHAR_CODE('quit')
kHICommandCancel                = FOUR_CHAR_CODE('not!')
kHICommandUndo                  = FOUR_CHAR_CODE('undo')
kHICommandRedo                  = FOUR_CHAR_CODE('redo')
kHICommandCut                   = FOUR_CHAR_CODE('cut ')
kHICommandCopy                  = FOUR_CHAR_CODE('copy')
kHICommandPaste                 = FOUR_CHAR_CODE('past')
kHICommandClear                 = FOUR_CHAR_CODE('clea')
kHICommandSelectAll             = FOUR_CHAR_CODE('sall')
kHICommandHide                  = FOUR_CHAR_CODE('hide')
kHICommandPreferences           = FOUR_CHAR_CODE('pref')
kHICommandZoomWindow            = FOUR_CHAR_CODE('zoom')
kHICommandMinimizeWindow        = FOUR_CHAR_CODE('mini')
kHICommandArrangeInFront        = FOUR_CHAR_CODE('frnt')

Mouse Tracking Result

kMouseTrackingMousePressed      = 1
kMouseTrackingMouseReleased     = 2
kMouseTrackingMouseExited       = 3
kMouseTrackingMouseEntered      = 4
kMouseTrackingMouseMoved        = 5

Data Types

typedef struct OpaqueEventRef *EventRef;
typedef struct OpaqueEventHandlerRef *EventHandlerRef;
typedef struct OpaqueEventHandlerCallRef *EventHandlerCallRef;
typedef struct OpaqueEventLoopRef *EventLoopRef;
typedef double EventTime;
typedef UInt16 MouseTrackingResult;

EventTypeSpec

struct EventTypeSpec 
{
  UInt32 eventClass;
  UInt32 eventKind;
};
typedef struct EventTypeSpec EventTypeSpec;

HICommand

struct HICommand 
{
  UInt32 attributes;
  UInt32 commandID;
  struct 
  {
    MenuRef menuRef;
    UInt16  menuItemIndex;
  } menu;
};
typedef struct HICommand HICommand;

Functions and Macros

Installing and Removing Event Handlers

OSStatus   InstallStandardEventHandler(EventTargetRef inTarget);
OSStatus   InstallEventHandler(EventTargetRef inTarget,EventHandlerUPP inHandler,
                               UInt32 inNumTypes,const EventTypeSpec *inList,
                               void *inUserData,EventHandlerRef *outRef);
#define    InstallApplicationEventHandler(h,n,l,u,r) \
               InstallEventHandler(GetApplicationEventTarget(),(h),(n),(l),(u),(r))
#define    InstallWindowEventHandler(t,h,n,l,u,r) \
               InstallEventHandler(GetWindowEventTarget(t),(h),(n),(l),(u),(r))
#define    InstallControlEventHandler(t,h,n,l,u,r) \
               InstallEventHandler(GetControlEventTarget(t),(h),(n),(l),(u),(r))
#define    InstallMenuEventHandler(t,h,n,l,u,r) \
               InstallEventHandler(GetMenuEventTarget(t),(h),(n),(l),(u),(r))
OSStatus   RemoveEventHandler(EventHandlerRef inHandlerRef);
OSStatus   AddEventTypesToHandler(EventHandlerRef inHandlerRef,UInt32 inNumTypes,
                                  const EventTypeSpec *inList);
OSStatus   RemoveEventTypesFromHandler(EventHandlerRef inHandlerRef, inNumTypes,
                                       const EventTypeSpec *inList);

Creating and Disposing of Event Handler UPPs

EventHandlerUPP NewEventHandlerUPP(EventHandlerProcPtr userRoutine);
void            DisposeEventHandlerUPP(EventHandlerUPP userUPP);

Running and Quitting Application Event Loop

void       RunApplicationEventLoop(void);
void       QuitApplicationEventLoop(void);

Getting Event Class and Kind

UInt32     GetEventClass(EventRef inEvent);
UInt32     GetEventKind(EventRef inEvent); 

Testing for User Cancelled

Boolean    IsUserCancelEventRef(EventRef event);

Getting Data From Events

OSStatus   GetEventParameter(EventRef inEvent,EventParamName inName,
                             EventParamType inDesiredType,EventParamType *outActualType,
                             UInt32 inBufferSize,UInt32 *outActualSize,void *ioBuffer);

Converting an Event Reference to an EventRecord

Boolean    ConvertEventRefToEventRecord(EventRef inEvent,EventRecord *outEvent);

Sending Events

OSStatus   SendEventToEventTarget(EventRef inEvent,EventTargetRef inTarget);
#define    SendEventToApplication(e) \
               SendEventToEventTarget((e),GetApplicationEventTarget())
#define    SendEventToWindow(e,t) \
               SendEventToEventTarget((e),GetWindowEventTarget(t))
#define    SendEventToControl(e,t) \
               SendEventToEventTarget((e),GetControlEventTarget(t))
#define    SendEventToMenu(e,t) \
               SendEventToEventTarget((e),GetMenuEventTarget(t))
#define    SendEventToUserFocus(e) \
               SendEventToEventTarget((e),GetUserFocusEventTarget())

Installing, Resetting, and Removing Timers

OSStatus   InstallEventLoopTimer(EventLoopRef inEventLoop, EventTimerInterval inFireDelay,
                                 EventTimerInterval inInterval,
                                 EventLoopTimerUPP inTimerProc,void *inTimerData,
                                 EventLoopTimerRef *outTimer);
OSStatus   SetEventLoopTimerNextFireTime(EventLoopTimerRef inTimer,
                                         EventTimerInterval inNextFire);
OSStatus   RemoveEventLoopTimer(EventLoopTimerRef inTimer); 

Calling Through to Handlers Below Current Handler

OSStatus   CallNextEventHandler(EventHandlerCallRef inCallRef,EventRef inEvent);

Getting Event and System Time

EventTime  GetEventTime(EventRef inEvent);
EventTime  GetCurrentEventTime(void);

Converting Between Ticks and EventTime

#define TicksToEventTime(t)  (EventTime) ((t) / 60.0)
#define EventTimeToTicks(t)  (UInt32)    ((t) * 60)

Mouse Tracking

OSStatus   TrackMouseLocation(GrafPtr inPort,Point *outPt,MouseTrackingResult *outResult);
OSStatus   TrackMouseRegion(GrafPtr inPort,RgnHandle inRegion,Boolean *ioWasInRgn,
           MouseTrackingResult *outResult);

Relevant Window Manager Constants and Functions

Constants

kWindowStandardHandlerAttribute = (1L << 25)

Functions

OSStatus   ChangeWindowAttributes(WindowRef window,WindowAttributes setTheseAttributes,
                                  WindowAttributes clearTheseAttributes);
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Netflix Games expands its catalogue with...
It is a good time to be a Netflix subscriber this month. I presume there's a good show or two, but we are, of course, talking about their gaming service that seems to be picking up steam lately. May is adding five new titles, and there are some... | Read more »
Seven Knights Idle Adventure drafts in a...
Seven Knights Idle Adventure is opening up more stages, passing the 15k mark, and players may find themselves in need of more help to clear these higher stages. Well, the cavalry has arrived with the introduction of the Legendary Hero Iris, as... | Read more »
AFK Arena celebrates five years of 100 m...
Lilith Games is quite the behemoth when it comes to mobile games, with Rise of Kingdom and Dislyte firmly planting them as a bit name. Also up there is AFK Arena, which is celebrating a double whammy of its 5th anniversary, as well as blazing past... | Read more »
Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »

Price Scanner via MacPrices.net

Deal Alert! 13-inch M2 MacBook Airs on record...
Amazon has 13″ MacBook Airs with M2 CPUs in stock and on sale this week for only $829 in Space Gray, Silver, Starlight, and Midnight colors. Their price is $170 off Apple’s MSRP, and it’s the lowest... Read more
Apple Watch Ultra 2 on sale for $50 off MSRP
Best Buy is offering Apple Watch Ultra 2 models for $50 off MSRP on their online store this week. Sale prices available for online orders only, in-store prices may vary. Order online, and choose free... Read more
Apple introduces the new M4-powered 11-inch a...
Today, Apple revealed the new 2024 M4 iPad Pro series, boasting a surprisingly thin and light design that pushes the boundaries of portability and performance. Offered in silver and space black... Read more
Apple introduces the new 2024 11-inch and 13-...
Apple has unveiled the revamped 11-inch and brand-new 13-inch iPad Air models, upgraded with the M2 chip. Marking the first time it’s offered in two sizes, the 11-inch iPad Air retains its super-... Read more
Apple discontinues 9th-gen iPad, drops prices...
With today’s introduction of the new 2024 iPad Airs and iPad Pros, Apple has (finally) discontinued the older 9th-generation iPad with a home button. In response, they also dropped prices on 10th-... Read more
Apple AirPods on sale for record-low prices t...
Best Buy has Apple AirPods on sale for record-low prices today starting at only $79. Buy online and choose free shipping or free local store pickup (if available). Sale price for online orders only,... Read more
13-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices, along with Amazon’s, are the lowest currently available for new 13″... Read more
Amazon is offering a $100 discount on every 1...
Amazon has every configuration and color of Apple’s 13″ M3 MacBook Air on sale for $100 off MSRP, now starting at $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD): $999 $100 off... Read more
Sunday Sale: Take $150 off every 15-inch M3 M...
Amazon is now offering a $150 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 15″ M3 MacBook... Read more
Apple’s 24-inch M3 iMacs are on sale for $150...
Amazon is offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150 off... Read more

Jobs Board

IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: May 8, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Nurse Anesthetist - *Apple* Hill Surgery Ce...
Nurse Anesthetist - Apple Hill Surgery Center Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
LPN-Physician Office Nurse - Orthopedics- *Ap...
LPN-Physician Office Nurse - Orthopedics- Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Read more
Supervisor/Therapist Rehabilitation Medicine...
Supervisor/Therapist Rehabilitation Medicine - Apple Hill (Outpatient Clinic) - Day Location: York Hospital, York, PA Schedule: Full Time Sign-On Bonus Eligible Read more
BBW Sales Support- *Apple* Blossom Mall - Ba...
BBW Sales Support- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 04388 Job Area: Store: Sales and Support Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.