Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Carbon Event Manager Reference (Legacy)
| Framework | Carbon/Carbon.h |
| Declared in | AEDataModel.h CarbonEvents.h CarbonEventsCore.h HIToolbar.h |
Overview
The Carbon Event Manager is the preferred API for handling events in Carbon applications. You can use this interface to handle events generated in response to user input as well as to create your own custom events. Because event handling is so fundamental to all applications, this document is relevant for everyone writing Carbon applications. To use this document, you should be familiar with Macintosh terminology and understand the basics of creating and manipulating the Mac OS user interface (windows, controls, menus, and so on).
For more information about HIObjects and the HIView subclass, see HIView Programming Guide.
Functions by Task
Creating and Manipulating Event Handlers
-
InstallEventHandler -
InstallStandardEventHandler -
RemoveEventHandler -
AddEventTypesToHandler -
RemoveEventTypesFromHandler -
CallNextEventHandler -
RegisterEventHotKey -
UnregisterEventHotKey -
RegisterToolboxObjectClassDeprecated in OS X v10.4 -
UnregisterToolboxObjectClassDeprecated in OS X v10.4
Creating and Manipulating Event Timers
Creating and Manipulating Events
-
GetEventClass -
GetEventKind -
GetEventParameter -
SetEventParameter -
CreateEvent -
CopyEvent -
CopyEventAs -
RetainEvent -
ReleaseEvent -
GetEventRetainCount -
ConvertEventRefToEventRecord -
IsEventInMask -
GetEventMonitorTarget
Dispatching Events
-
SendEventToEventTarget -
SendEventToEventTargetWithOptions -
GetControlEventTarget -
GetWindowEventTarget -
GetMenuEventTarget -
GetApplicationEventTarget -
GetEventDispatcherTarget -
GetUserFocusEventTarget -
ProcessHICommand
Managing Secure Event Input
Managing Event Queues
-
GetCurrentEventQueue -
GetMainEventQueue -
PostEventToQueue -
RemoveEventFromQueue -
IsEventInQueue -
AcquireFirstMatchingEventInQueue -
FlushEventsMatchingListFromQueue -
FindSpecificEventInQueue -
FlushSpecificEventsFromQueue -
FlushEventQueue -
GetNumEventsInQueue
Managing the Event Loop
-
RunApplicationEventLoop -
QuitApplicationEventLoop -
GetMainEventLoop -
GetCurrentEventLoop -
GetCFRunLoopFromEventLoop -
RunCurrentEventLoop -
QuitEventLoop -
ReceiveNextEvent
Manipulating Event Time
Implementing Modal Windows
-
RunAppModalLoopForWindow -
QuitAppModalLoopForWindow -
BeginAppModalStateForWindow -
EndAppModalStateForWindow
Tracking the Mouse
-
TrackMouseLocation -
TrackMouseLocationWithOptions -
TrackMouseRegion -
HIMouseTrackingGetParameters -
ChangeMouseTrackingRegionDeprecated in OS X v10.4 -
ClipMouseTrackingRegionDeprecated in OS X v10.4 -
ClipWindowMouseTrackingRegionsDeprecated in OS X v10.4 -
CreateMouseTrackingRegionDeprecated in OS X v10.4 -
GetMouseTrackingRegionIDDeprecated in OS X v10.4 -
GetMouseTrackingRegionRefConDeprecated in OS X v10.4 -
MoveMouseTrackingRegionDeprecated in OS X v10.4 -
MoveWindowMouseTrackingRegionsDeprecated in OS X v10.4 -
ReleaseMouseTrackingRegionDeprecated in OS X v10.4 -
ReleaseWindowMouseTrackingRegionsDeprecated in OS X v10.4 -
RetainMouseTrackingRegionDeprecated in OS X v10.4 -
SetMouseTrackingRegionEnabledDeprecated in OS X v10.4 -
SetWindowMouseTrackingRegionsEnabledDeprecated in OS X v10.4
Working with Hot Keys
Callback-Related Functions
-
NewEventComparatorUPP -
InvokeEventComparatorUPP -
DisposeEventComparatorUPP -
NewEventHandlerUPP -
DisposeEventHandlerUPP -
InvokeEventHandlerUPP -
NewEventLoopTimerUPP -
InvokeEventLoopTimerUPP -
DisposeEventLoopTimerUPP -
NewEventLoopIdleTimerUPP -
InvokeEventLoopIdleTimerUPP -
DisposeEventLoopIdleTimerUPP
Miscellaneous
Functions
AcquireFirstMatchingEventInQueue
Obtains the first event that matches the specified list of event classes and kinds.
EventRef AcquireFirstMatchingEventInQueue ( EventQueueRef inQueue, ItemCount inNumTypes, const EventTypeSpec *inList, OptionBits inOptions );
Parameters
- inQueue
The queue to check.
- inNumTypes
The number of event kinds for which to search. You may pass
0if you also passNULLforinList.- inList
The list of event classes and kinds to search for in the queue. You may pass
NULLifinNumTypesis0. Doing so effectively matches any event in the queue and causes this function to return the first event in the queue.- inOptions
Must be
kEventQueueOptionsNone.
Return Value
An event reference, or NULL if no events match. The reference count for the event has been incremented (that is, it has been retained), so you must release the event reference.
Discussion
This function does not remove the event from the queue. To remove the event, call RemoveEventFromQueue.
This function does not call the run loop, so no timers fire as a result of calling this function. This function does not cause any window flushing to occur, but it does get new events from the window server.
This function should have better performance characteristics than the older EventAvail API.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEventsCore.hAddEventTypesToHandler
Adds events to an installed handler.
OSStatus AddEventTypesToHandler ( EventHandlerRef inHandlerRef, ItemCount inNumTypes, const EventTypeSpec *inList );
Parameters
- inHandlerRef
The event handler to add events to.
- inNumTypes
The number of events to add.
- inList
A pointer to an array of
EventTypeSpecstructures.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
You can use this function to dynamically change which events you want your handler to respond to.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hBeginAppModalStateForWindow
Puts the window in an application-modal state, but does not process events.
OSStatus BeginAppModalStateForWindow ( WindowRef inWindow );
Parameters
- inWindow
The window you wish to behave modally. See the Window Manager documentation for a description of the
WindowRefdata type.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is a lower level function than RunAppModalLoopForWindow. You use it if you want to enter an application modal state for a window but need to control the event loop yourself. Once you begin your application modal state, the menu bar will disable and prepare for the modal situation. You can then call low-level functions (such as ReceiveNextEvent) to run the event loop and process events.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hCallNextEventHandler
Calls the next handler in the handler chain.
OSStatus CallNextEventHandler ( EventHandlerCallRef inCallRef, EventRef inEvent );
Parameters
- inCallRef
The event handler call reference passed into your event handler.
- inEvent
The event you want to pass to the next handler.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Calls through to the event handlers below you in the event handler stack of the target to which your handler is bound. You might use this to call through to the default toolbox handling in order to post-process the event. You can only call this routine from within an event handler.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hConvertEventRefToEventRecord
Converts an event reference into an event record.
Boolean ConvertEventRefToEventRecord ( EventRef inEvent, EventRecord *outEvent );
Parameters
- inEvent
The event reference to convert.
- outEvent
The event record to fill out. See the Event Manager documentation for a description of the
EventRecorddata type.
Return Value
A Boolean value indicating whether the conversion was successful (true) or not (false).
Discussion
This function helps you when you need an EventRecord structure and all you have is a Carbon event reference. If the event can be converted, outEvent is filled in and the function returns true. If not, the function returns false and outEvent contains nullEvent.
This function can convert the following events:
kEventMouseDown,kEventMouseUp,kEventMouseMoved, andkEventMouseDragged(kEventClassMouse)kEventRawKeyDown,kEventRawKeyUp, andkEventRawKeyRepeat(kEventClassKeyboard)kEventWindowUpdate,kEventWindowActivate,kEventWindowDeactivate, andkEventWindowCursorChange(kEventClassWindow)kEventAppActivatedandkEventAppDeactivate(kEventClassApplication)kEventAppleEvent(kEventClassAppleEvents)kEventControlTrack(kEventClassControl) is converted to a mouse down event in Mac OS X v10.4 and later
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hCopyEvent
Copies an event.
EventRef CopyEvent ( EventRef inOther );
Parameters
- inOther
The event to copy.
Return Value
A new event reference for the specified event.
Discussion
The CopyEvent function makes an exact duplicate of an existing event reference. The reference count for the duplicate event reference is set to 1.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hCopyEventAs
Copies an existing event, allowing you to change the class and kind of the event.
EventRef CopyEventAs ( CFAllocatorRef inAllocator, EventRef inOther, OSType inEventClass, UInt32 inEventKind );
Parameters
- inOther
The allocator to use to allocate the event data. Pass
NULLorkCFAllocatorDefaultto use the standard allocator.- inOther
The event to copy.
- inEventClass
The new event class for the copy of the event.
- inEventKind
The new event kind for the copy of the event.
Return Value
A new event reference or NULL if the inOther was NULL or memory for the new event could not be allocated.
Discussion
The CopyEventAs is useful during event flow and transformation. For example, this function is used when upgrading a raw mouse down to a window click event, to ensure that the window click event has exactly the same parameters as the original mouse down event.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEventsCore.hCopyServicesMenuCommandKeys
Obtains information about command key shortcuts in an application’s Services menu.
OSStatus CopyServicesMenuCommandKeys ( CFArrayRef *outCommandKeyArray );
Parameters
- outCommandKeyArray
On return, an array of items in the Services menu that have command key shortcuts associated with them.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Each array entry is a reference to a CFDictionary, and each dictionary contains information about a single command key shortcut for items in the application’s Services menu. Each dictionary contains the following keys: kHIServicesMenuProviderName, kHIServicesMenuItemName, kHIServicesMenuCharCode, and kHIServicesMenuKeyModifiers. The array must be released by the caller. The dictionaries do not need to be released because they are released automatically when the array is released.
Availability
- Available in OS X v10.4 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hCopySymbolicHotKeys
Obtains information about symbolic hot keys in the Keyboard preferences pane.
OSStatus CopySymbolicHotKeys ( CFArrayRef *outHotKeyArray );
Parameters
- outHotKeyArray
An array of dictionaries containing information about the systemwide symbolic hot keys defined in the Keyboard preferences pane, such as the Screen Capture, Universal Access, and Keyboard Navigation keys. The array does not include information about custom, application-specific command keys. You must release the array when you no longer need it. The dictionaries are automatically released when you release the array.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Each array entry is a reference for a CFDictionary, and each dictionary contains information about a single hot key. There is currently no way to determine which hot key in the Keyboards preference pane corresponds to a specific dictionary. Each dictionary contains the following keys: kHISymbolicHotKeyCode, kHISymbolicHotKeyModifiers, and kHISymbolicHotKeyEnabled. For details, see “Symbolic Hot Key Definitions.”
The number of hot keys will increase in the future, so do not call this function unnecessarily or in highly performance-sensitive code.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEvents.hCreateEvent
Creates an event.
OSStatus CreateEvent ( CFAllocatorRef inAllocator, UInt32 inClassID, UInt32 kind, EventTime when, EventAttributes flags, EventRef * outEvent );
Parameters
- inAllocator
A reference to the desired memory allocator to use to allocate memory for the event. Pass
NULLto use the default allocator. See the Base Services documentation for a description of theCFAllocatorRefdata type.- inClassID
The event class of the event to create.
- kind
The event kind of the event to create.
- when
The time the event occurred. Pass
0to specify the current event time (as returned by theGetCurrentEventTimefunction).- flags
The event attributes to set. Currently you can pass
kEventAttributeNoneorkEventAttributeUserEvent.- outEvent
On return, a reference to the newly created event.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
You can use this function to create your own custom events or to simulate existing events. If you are creating custom events, you must make sure that the event signature (the combination of event class and event kind) does not conflict with any existing events.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hCreateTypeStringWithOSType
Converts an OSType string to a Core Foundation string.
CFStringRef CreateTypeStringWithOSType ( OSType inType );
Return Value
The Core Foundation string version of the OSType string. A return value of NULL indicates that an error occurred. See the Base Services documentation for a description of the CFStringRef data type.
Discussion
You can use this function to create CFString versions of OSType data types to pass to the Services Manager. As this is a creation function, you must call CFRelease on your Core Foundation string when you no longer need it.
Availability
- Available in OS X v10.1 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hDisableSecureEventInput
Disables secure event input mode.
OSStatus DisableSecureEventInput ( void );
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
When secure event input mode is enabled, keyboard input goes only to the application with keyboard focus and is not echoed to other applications that might be using the event monitor target to watch keyboard input. The EditText and EditUnicodeText controls automatically enter secure input mode when a password control has focus. If your application implements its own password entry, you should enable secure event input while the user enters text.
This function maintains a count of the number of times that it has been called. Secure event input is not disabled until DisableSecureEventInput has been called the same number of times. Be sure to disable secure event input if your application becomes inactive. If your application crashes, secure event input is automatically disabled if no other application has enabled it.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEventsCore.hDisposeEventComparatorUPP
Disposes of an event comparator UPP.
void DisposeEventComparatorUPP ( EventComparatorUPP userUPP );
Parameters
- userUPP
The UPP you want to destroy.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hDisposeEventHandlerUPP
Disposes of an event handler UPP.
void DisposeEventHandlerUPP ( EventHandlerUPP userUPP );
Parameters
- userUPP
The event handler UPP you want to destroy.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hDisposeEventLoopIdleTimerUPP
Disposes of an event loop idle timer.
void DisposeEventLoopIdleTimerUPP ( EventLoopIdleTimerUPP userUPP );
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hDisposeEventLoopTimerUPP
Disposes of an event loop timer.
void DisposeEventLoopTimerUPP ( EventLoopTimerUPP userUPP );
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEnableSecureEventInput
Enables secure event input mode.
OSStatus EnableSecureEventInput ( void );
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
When secure event input mode is enabled, keyboard input goes only to the application with keyboard focus and is not echoed to other applications that might be using the event monitor target to watch keyboard input. The EditText and EditUnicodeText controls automatically enter secure input mode when a password control has focus. If your application implements its own password entry, you should enable secure event input while the user enters text.
This function maintains a count of the number of times that it has been called. Secure event input is not disabled until DisableSecureEventInput has been called the same number of times. Be sure to disable secure event input if your application becomes inactive. If your application crashes, secure event input is automatically disabled if no other application has enabled it.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEventsCore.hEndAppModalStateForWindow
Ends the application-modal state entered using the function BeginAppModalStateForWindow.
OSStatus EndAppModalStateForWindow ( WindowRef inWindow );
Parameters
- inWindow
The window you wish to stop acting as application- modal. See the Window Manager documentation for a description of the
WindowRefdata type.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This routine ends an app modal state started with BeginAppModalStateForWindow.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hFindSpecificEventInQueue
Finds a specific event in the event queue.
EventRef FindSpecificEventInQueue ( EventQueueRef inQueue, EventComparatorUPP inComparator, void *inCompareData );
Parameters
- inQueue
The event queue to search.
- inComparator
The comparison function to invoke for each event in the queue. See
EventComparatorProcPtrfor the required format of your comparison function A return value oftruefrom the comparator indicates a match.- inCompareData
The data you wish to pass to your comparison function.
Return Value
An event reference.
Discussion
Returns the first event that matches a comparator function, or NULL if no events match.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hFlushEventQueue
Removes all events from the event queue.
OSStatus FlushEventQueue ( EventQueueRef inQueue );
Parameters
- inQueue
The event queue to flush.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Flushes all events from an event queue.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hFlushEventsMatchingListFromQueue
Removes events from the event queue by kind and class.
OSStatus FlushEventsMatchingListFromQueue ( EventQueueRef inQueue, ItemCount inNumTypes, const EventTypeSpec *inList );
Parameters
- inQueue
The event queue to flush events from.
- inNumTypes
The number of event kinds to flush.
- inList
The list of event classes and kinds to flush from the queue.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hFlushSpecificEventsFromQueue
Removes specified events from the event queue.
OSStatus FlushSpecificEventsFromQueue ( EventQueueRef inQueue, EventComparatorUPP inComparator, void *inCompareData );
Parameters
- inQueue
The event queue to flush events from.
- inComparator
The comparison function to invoke for each event in the queue. See
EventComparatorProcPtrfor the required format of your comparison function. A return value oftruefrom the comparator indicates that the event should be flushed.- inCompareData
The data you wish to pass to your comparison function.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetApplicationEventTarget
Obtains the event target reference for the application.
EventTargetRef GetApplicationEventTarget ( void );
Return Value
An event target reference.
Discussion
Once you obtain this reference, you can send events to the target and install event handlers on it.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hGetCFRunLoopFromEventLoop
Obtains a Core Foundation CFRunLoop from an Carbon event loop reference.
CFTypeRef GetCFRunLoopFromEventLoop ( EventLoopRef inEventLoop );
Parameters
- inEventLoop
The event loop reference to translate.
Return Value
A reference to the CFRunLoop.
Discussion
There isn’t necessarily a one-to-one correspondence between Carbon event loops and Core Foundation event loops, so you should use this function instead of simply calling the Core Foundation function CFRunLoopGetCurrent.
Availability
- Available in OS X v10.1 and later.
Declared In
CarbonEventsCore.hGetControlEventTarget
Obtains the event target reference for the specified control.
EventTargetRef GetControlEventTarget ( ControlRef inControl );
Parameters
- inControl
The control to return the target for. See the Control Manager documentation for a description of the
ControlRefdata type.
Return Value
An event target reference.
Discussion
Once you obtain this reference, you can send events to the target and install event handlers on it.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hGetCurrentEventKeyModifiers
Obtains the queue-synchronized keyboard modifier state.
UInt32 GetCurrentEventKeyModifiers ( void );
Return Value
A bit field indicating the queue-synchronized keyboard modifier state. This field is the same as the modifiers field returned in an Event Manager EventRecord structure, but it includes only the keyboard modifier flags.
Discussion
The queue-synchronized keyboard modifier state indicates the modifier state according to the event most recently dispatched through an event target. This state may be different from the hardware state obtained using GetCurrentKeyModifiers. For example, say the user invokes a Control-click with the mouse. If the user releases or changes a modifier key before the mouse down event is dispatched, the hardware state reflects the new modifier state, not the one that generated the original mouse event.
The most recently dispatched event may not necessarily be the event that your event handler is handling. For example, if a mouse-down event occurs, and you have a handler for the kEventWindowHandleContentClick event that is generated from the mouse-down, then the keyboard modifiers will be those that were attached to the mouse-down. The content-click event itself has a kEventParamKeyModifiers parameter, which is copied from the mouse-down event, but GetCurrentEventKeyModifiers returns the modifiers from the mouse-down, not from the content-click event, because it was the mouse-down event that was most recently dispatched through the event dispatcher.
Events that are not sent through the event dispatcher target will not update the current event key modifiers. Also, events arriving from outside the application, such as an AppleEvent or an Accessibility event, also will not update the modifiers. If your application modifies its behavior based on modifier state, you should parameterize your core code with the event modifiers, and determine the modifiers based on the origin of the behavior request. For a request that originates directly from user input, you can use GetCurrentEventKeyModifiers, but for a request that originates from an AppleEvent or Accessibility event, you would probably use no modifiers. GetCurrentEventKeyModifiers gives a more consistent user experience when the user input queue is being remote controlled or manipulated via non-hardware event sources such as speech or AppleEvents; using GetCurrentEventKeyModifiers is also much faster than using EventAvail(0, &eventRecord) or GetCurrentKeyModifiers.
GetCurrentEventKeyModifiers returns a valid modifier state only if your application is the active application. If your application is not active, then user input events are not flowing through the event dispatcher and the queue-synchronized state is not updated.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hGetCurrentEventLoop
Obtains a reference to the current event loop.
EventLoopRef GetCurrentEventLoop ( void );
Return Value
An event loop reference.
Discussion
This function returns the event loop for the current thread. If the current thread is a cooperative thread, the main event loop is returned.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetCurrentEventQueue
Obtains the current event queue.
EventQueueRef GetCurrentEventQueue ( void );
Return Value
An event queue reference.
Discussion
This function obtains the event queue for the current thread. If the current thread is a cooperative thread, the main event queue is returned.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetCurrentEventTime
Returns the current time since last system startup, in seconds.
EventTime GetCurrentEventTime ( void );
Return Value
EventTime.
Discussion
Returns the current time since last system startup in seconds.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetEventClass
Returns the class of an event (for example, window, mouse, or keyboard).
OSType GetEventClass ( EventRef inEvent );
Parameters
- inEvent
The event in question.
Return Value
The class ID of the event. See “Event Class Constants” for more details.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetEventDispatcherTarget
Obtains the event target reference for the standard toolbox dispatcher.
EventTargetRef GetEventDispatcherTarget ( void );
Return Value
An event target reference.
Discussion
The standard toolbox dispatcher is the default mechanism for dispatching events to the appropriate event targets. You typically don’t need to call this, but some applications may need to pick events off the event queue and call the dispatcher themselves. This allows you to do just that instead of calling RunApplicationEventLoop to handle it all.
If desired, you can attach event handlers to the event dispatcher target. Doing so allows you to intercept any events before they can be sent to the appropriate event targets.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hGetEventKind
Returns the event kind for the specified event.
UInt32 GetEventKind ( EventRef inEvent );
Parameters
- inEvent
The event in question.
Return Value
The kind of the event.
Discussion
Event kind values overlap in different event classes. For example, kEventMouseDown and kEventAppActivated both have the same value (1). The combination of class and kind determines a unique event signature.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetEventMonitorTarget
Obtains an event monitor target.
EventTargetRef GetEventMonitorTarget ( void );
Return Value
An event monitor target.
Discussion
The event monitor target is a special event target used to monitor user input events across all processes.
When an event handler is installed on the event monitor target, the Carbon Event Manager examines the EventTypeSpec for user input event types, such as mouse-down, mouse-up, and key-down. It then requests that the WindowServer make copies of any of these events that are sent to any process, and delivers them to the current process. These events are queued into the main thread’s event queue and are sent directly to the event handlers installed on the event monitor target during normal event dispatching.
Monitored events are not sent through the normal event dispatching path for the current process. Instead, they pass through the event dispatcher target and are sent directly to the event monitor target.
Handlers installed on the event monitor target receive events only when the current application is inactive. When the current application is active, all events flow through the event dispatcher target, and no events are sent to the event monitor target.
Currently, the event monitor supports the following event kinds: kEventRawKeyDown, kEventRawKeyUp, kEventRawKeyRepeat, kEventRawKeyModifiersChange, kEventMouseDown, kEventMouseUp, kEventMouseMoved, kEventMouseDragged, kEventMouseWheelMoved, kEventTabletPoint, and kEventTabletProximity.
To prevent keyboard events from being passed to other applications, Carbon and Cocoa password-edit-text controls enable a secure input mode while the focus is on the control. Their password-edit-text controls prevent the monitoring event target from being used to capture password keystrokes.
Although efforts have been made to limit input to the application with keyboard focus, this mechanism is not intended to guard against rogue applications. It is provided to guard against other people looking over the user’s shoulder at the screen.
For added security, GetEventMonitorTarget requires that “Enable access for assistive devices” be checked in the Universal Access preference pane in order to monitor kEventRawKeyDown, kEventRawKeyUp, and kEventRawKeyRepeat events. If this control is not checked, you can still install handlers for these events on the event monitor target, but no events of these types will be sent to your handler. Administrator privileges are required to enable this feature. You can determine whether this control is checked using the AXAPIEnabled function in AXUIElement.h.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEvents.hGetEventParameter
Obtains a parameter from the specified event.
OSStatus GetEventParameter ( EventRef inEvent, EventParamName inName, EventParamType inDesiredType, EventParamType *outActualType, ByteCount inBufferSize, ByteCount *outActualSize, void *outData );
Parameters
- inEvent
The event to get the parameter from.
- inName
The symbolic name of the parameter (for example,
kEventParamDirectObject). The Carbon Event Manager defines a number of constants defining possible parameters.- inDesiredType
The desired type of the parameter (for example,
typeWindowRef). The Carbon Event Manager automatically uses AppleEvent coercion handlers to convert the data in the event into the desired type, if possible. The Carbon Event Manager defines a number of constants to indicate possible parameter types. PasstypeWildCardto request that the data be returned in its original format.- outActualType
The actual type of the parameter (can be
NULLif you are not interested in receiving this information).- inBufferSize
The size of the output buffer.
- outActualSize
The actual size of the data, or
NULLif you don’t want this information.- outData
The pointer to the buffer receiving the parameter data.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Events often contain additional useful pieces of data, such as the location of a mouse-down event or the window in which an event occurred.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetEventRetainCount
Returns the reference count of an event.
ItemCount GetEventRetainCount ( EventRef inEvent );
Return Value
The current reference count for the specified event.
Discussion
When an event is created, its reference count is 1. Calls to RetainEvent increment this count; calls to ReleaseEvent decrement the count.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetEventTime
Returns the time a specific event occurred.
EventTime GetEventTime ( EventRef inEvent );
Parameters
- inEvent
The event in question.
Return Value
The time the event occurred.
Discussion
Returns the time the event specified occurred, specified as an EventTime value, which is a floating point number representing seconds since the last system startup.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetLastUserEventTime
Returns the last time a user input event arrived in the main event queue of the application.
EventTime GetLastUserEventTime ( void );
Return Value
The time of the last user event.
Discussion
A user input event is something generated by the user, typically a hardware event such as a mouse-click or key-down event.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hGetMainEventLoop
Obtains a reference to the main event loop.
EventLoopRef GetMainEventLoop ( void );
Return Value
An event loop reference.
Discussion
The main loop is the event loop for the main application thread.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetMainEventQueue
Obtains the main event queue.
EventQueueRef GetMainEventQueue ( void );
Return Value
An event queue reference.
Discussion
The main queue is the event queue for the main application thread.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetMenuEventTarget
Obtains an event target reference for the specified menu.
EventTargetRef GetMenuEventTarget ( MenuRef inMenu );
Parameters
- inMenu
The menu to return the target for. See the Menu Manager documentation for a description of the
MenuRefdata type.
Return Value
An event target reference.
Discussion
Once you obtain this reference, you can send events to the target and install event handlers on it.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hGetNumEventsInQueue
Returns the number of events in the event queue.
ItemCount GetNumEventsInQueue ( EventQueueRef inQueue );
Parameters
- inQueue
The event queue to query.
Return Value
The number of items in the queue.
Discussion
Returns the number of events in an event queue.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hGetSymbolicHotKeyMode
Obtains the current hot key mode.
OptionBits GetSymbolicHotKeyMode ( void );
Return Value
The mode request at the top of the hot key mode stack. If there are no mode requests on the stack, this function returns 0 to indicate that hot keys are currently enabled.
Discussion
Unless the “Enable access for assistive devices” checkbox is checked in the Universal Access preference pane, all hot keys are enabled, even if this function returns a nonzero value. This means that hot keys enabled by the caller may be disabled for the current user session if they were disabled by another process.
Availability
- Available in OS X v10.4 and later.
Declared In
CarbonEvents.hGetUserFocusEventTarget
Obtains the event target reference for the user focus.
EventTargetRef GetUserFocusEventTarget ( void );
Return Value
An event target reference.
Discussion
This event target always references the current user focus. For example, if you install a handler on this target, then your handler will be called whenever an event is sent to the user focus. Keyboard events are always sent to this target.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hGetWindowEventTarget
Obtains the event target reference for a specified window.
EventTargetRef GetWindowEventTarget ( WindowRef inWindow );
Parameters
- inWindow
The window to return the event target for. See the QuickDraw Manager documentation for a description of the
WindowRefdata type.
Return Value
An event target reference.
Discussion
Once you obtain this reference, you can send events to the target and install an event handler on it.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hHIMouseTrackingGetParameters
Obtains information about how mouse tracking loops should behave.
OSStatus HIMouseTrackingGetParameters ( OSType inSelector, EventTime *outTime, HISize *outDistance );
Parameters
- inSelector
The type of information to obtain. Currently, the only supported selector is
kMouseParamsSticky.- outTime
When sticky mode is select, on return, the maximum time between mouse-down and mouse-up. If the time between events is longer than this value, sticky mode should not be invoked. Pass
NULLif you don’t need this information.- outDistance
When sticky mode is select, on return, the maximum distance between mouse-down and mouse-up. If the distance between events is longer than this value, sticky mode should not be invoked. Pass
NULLif you don’t need this information.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Mouse tracking loops use different timeouts and wander distances to determine their behavior. This function provides a generic service for requesting this information.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEvents.hInstallEventHandler
Installs an event handler on a specified event target.
OSStatus InstallEventHandler ( EventTargetRef inTarget, EventHandlerUPP inHandler, ItemCount inNumTypes, const EventTypeSpec *inList, void *inUserData, EventHandlerRef *outRef );
Parameters
- inTarget
The event target to register your handler with.
- inHandler
A pointer to your event handler function.
- inNumTypes
The number of events you are registering for.
- inList
A pointer to an array of
EventTypeSpecentries representing the events you are interested in.- inUserData
The value you pass in this parameter is passed to your event handler function when it is called.
- outRef
On return, an event handler reference, which you can use later to remove the handler. You can pass
NULLif you don’t want the reference—when the target is disposed, the handler is disposed as well.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
After being installed, your handler will be called when an event you registered for is sent to the specified event target. Note that CarbonEvents.h defines several macros which you can use for particular event classes. These macros simply combine the appropriate GetxxxEventTarget call with InstallEventHandler.
InstallApplicationEventHandlerInstallWindowEventHandlerInstallControlEventHandlerInstallMenuEventHandlerInstallHIObjectEventHandler(in Mac OS X v10.2 and later)HIViewInstallEventHandler(in Mac OS X v10.2 and later)
Be sure to remove the event handler when you no longer need it by calling RemoveEventHandler. Doing so is especially important if the handler calls code that may disappear. For example, if a plugin installs an event handler and is later removed without removing the handler, the system may attempt to call back to the now nonexistent plugin code.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hInstallEventLoopIdleTimer
Installs a timer that fires only when there is no user activity.
OSStatus InstallEventLoopIdleTimer ( EventLoopRef inEventLoop, EventTimerInterval inDelay, EventTimerInterval inInterval, EventLoopIdleTimerUPP inTimerProc, void *inTimerData, EventLoopTimerRef *outTimer );
Parameters
- inEventLoop
The event loop to add the timer.
- inFireDelay
The delay before first firing this timer, in seconds. In Mac OS X v10.3 and earlier, this delay must be greater than zero. In Mac OS X v10.4 and later, the delay must be greater than or equal to zero. You cannot pass
kEventDurationForever.- inInterval
The timer interval, in seconds. Pass
0orkEventDurationForeverfor a one-shot timer.- inTimerProc
The function to call when the timer fires.
- inTimerData
Data to pass to the timer function when called.
- outTimer
A reference to the newly installed timer.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
An idle timer is the same as a standard event timer except that it fires only when no user events are being received. That is, if the system receives no user events for the inFireDelay delay time, the idle timer fires, and will continue to fire at the rate specified by inInterval. If the user begins activity again, the timer stops and resets. For example, you could use an idle timer in a search engine to begin a search 2 seconds after the user stops typing in the search text field.
The callback function for idle timers takes an additional parameter that tells the callback the user status. See EventLoopIdleTimerProcPtr and “Idle Timer Event Constants” for more information.
Be sure to dispose of the timer when you no longer need it by calling RemoveEventLoopTimer. Doing so is especially important if your timer calls code that may no longer exist. For example, if a plugin creates a timer that calls back to it, the timer will attempt to call it even after the plugin is removed.
Availability
- Available in OS X v10.2 and later.
- Not available to 64-bit applications.
Declared In
CarbonEventsCore.hInstallEventLoopTimer
Installs a timer.
OSStatus InstallEventLoopTimer ( EventLoopRef inEventLoop, EventTimerInterval inFireDelay, EventTimerInterval inInterval, EventLoopTimerUPP inTimerProc, void *inTimerData, EventLoopTimerRef *outTimer );
Parameters
- inEventLoop
The event loop to add the timer.
- inFireDelay
The delay before first firing this timer, in seconds. In Mac OS X v10.3 and earlier, the delay must be greater than zero. In Mac OS X v10.4, the delay can be greater than or equal to zero.
In Mac OS X and CarbonLib 1.5 and later, you may pass
kEventDurationForeverto stop the timer from firing at all untilSetEventLoopTimerNextFireTimeis used to start it; in earlier versions of CarbonLib, to achieve the same effect, just pass zero and then immediately callSetEventLoopTimerNextFireTime( timer, (kEventDurationForever )before returning control to your event loop.- inInterval
The timer interval, in seconds. Pass
0or (in Mac OS X and CarbonLib 1.5 and later)kEventDurationForeverfor a one-shot timer.- inTimerProc
The function to call when the timer fires.
- inTimerData
Data to pass to the timer function when called.
- outTimer
A reference to the newly installed timer.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Installs a timer onto the event loop specified. The timer can either fire once or repeatedly at a specified interval depending on the parameters passed to this function. 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 functions, allocate memory, and draw without worrying about consequences. When a timer fires, it calls the callback you specified when the timer was 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, and so on.
One advantage of timers is that you can install the timer right from the code that wants the time. For example, the standard editable text control can install a timer to blink the cursor when it’s active, meaning that the Control Manager function 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.
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.
Be sure to dispose of the timer when you no longer need it by calling RemoveEventLoopTimer. Doing so is especially important if your timer calls code that may no longer exist. For example, if a plugin creates a timer that calls back to it, the timer will attempt to call it even after the plugin is removed.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hInstallStandardEventHandler
Installs the standard event handler for the specified target.
OSStatus InstallStandardEventHandler ( EventTargetRef inTarget );
Parameters
- inTarget
The event target for which you want to install the standard handler.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Currently you can install the standard handler only for window event targets. To install the standard application handler, you must call RunApplicationEventLoop.
Note that events may also have default behaviors or standard definitions which define how an event is handled if you choose not to handle it yourself. Default behavior is the response that occurs whenever you choose not to handle the event, whether or not you have a standard handler installed. Standard definition behavior defines how an event is handled based on that element’s standard definition. For example, the standard menu definition provides some default responses for menu events you do not handle. However if you are using your own custom definition, you cannot assume that these default responses will occur.
You can also install the standard handler for a window event target by calling ChangeWindowAttributes to set the kWindowStandardHandlerAttribute window attribute on the window.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEventsCore.hInvokeEventComparatorUPP
Calls an event comparator function through a UPP.
Boolean InvokeEventComparatorUPP ( EventRef inEvent, void *inCompareData, EventComparatorUPP userUPP );
Parameters
- inEvent
The event to compare against.
- inCompareData
Application-specific data. Typically this is the data you passed when calling
FindSpecificEventInQueueorFlushSpecificEventsFromQueue.- userUPP
A UPP to the comparator function you want to invoke.
Return Value
Returns true if the comparator function indicates a match with the specified event, false otherwise.
Discussion
You call this function only if you need to invoke your event comparator callback yourself. In most cases you don’t need to call this function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hInvokeEventHandlerUPP
Calls an event handler through a UPP.
OSStatus InvokeEventHandlerUPP ( EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData, EventHandlerUPP userUPP );
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
You use this function only if you need to invoke an event handler yourself. In most cases you don’t need to call this function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hInvokeEventLoopIdleTimerUPP
Calls an event loop idle timer through a UPP.
void InvokeEventLoopIdleTimerUPP ( EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData, EventLoopIdleTimerUPP userUPP );
Discussion
You use this function only if you need to invoke an idle event timer callback yourself. In most cases you don’t need to call this function.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hInvokeEventLoopTimerUPP
Calls an event loop timer through a UPP.
void InvokeEventLoopTimerUPP ( EventLoopTimerRef inTimer, void *inUserData, EventLoopTimerUPP userUPP );
Discussion
You use this function only if you need to invoke an event timer callback yourself. In most cases you don’t need to call this function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hIsEventInMask
Determines whether an event reference matches a WaitNextEvent-style event mask.
Boolean IsEventInMask ( EventRef inEvent, EventMask inMask );
Parameters
- inEvent
The event reference to check against the event mask.
- inMask
The mask to consider. See the Event Manager documentation for a description of the
EventMaskdata type.
Return Value
A Boolean whose value is TRUE if the event was in the mask; otherwise, FALSE.
Discussion
This is a companion function for ConvertEventRefToEventRecord, and is provided as a convenience function to help you if there are places in your application where you want to check an EventRef to see if it matches a classic EventMask bitfield. If the event matches, the function returns true.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hIsEventInQueue
Determines whether an event is in a particular queue.
Boolean IsEventInQueue ( EventQueueRef inQueue, EventRef inEvent );
Parameters
- inQueue
The queue to check.
- inEvent
The event in question.
Return Value
Returns true if the specified event is posted to a queue.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hIsMouseCoalescingEnabled
Indicates whether mouse coalescing is enabled.
Boolean IsMouseCoalescingEnabled ( void );
Return Value
A Boolean whose value is TRUE if mouse coalescing is on; otherwise, FALSE.
Discussion
If mouse coalescing is enabled, intermediate mouse movement events are merged into the most recent event, so that only one mouse moved or mouse dragged event is in the event queue at any time. For example, when the user moves the mouse across the screen, more mouse moved events are generated than most applications care about. Rather than place all these events in the queue (which would probably slow down the application), the Carbon Event Manager first checks to see if a mouse moved event already exists. If a mouse moved event already exists, that event is updated with the position and delta information from the more recently-generated event.
Availability
- Available in OS X v10.1 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hIsSecureEventInputEnabled
Determines whether secure event input mode is enabled.
Boolean IsSecureEventInputEnabled ( void );
Return Value
A Boolean whose value is TRUE if secure event input mode is enabled; otherwise, FALSE.
Discussion
This function determines whether secure event input is enabled by any process, not just the current process. Secure event input may be disabled in the current process but enabled in another process, in which case, this function returns TRUE.
Availability
- Available in OS X v10.3 and later.
Declared In
CarbonEventsCore.hIsUserCancelEventRef
Returns whether the specified event indicates the user wishes to cancel an operation.
Boolean IsUserCancelEventRef ( EventRef event );
Return Value
A Boolean value indicating whether the event is a user cancel event.
Discussion
Tests the event given to see whether the event represents a user cancel event. Currently this is defined to be either the escape key being pressed or command-period being pressed.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hNewEventComparatorUPP
Creates an event comparator UPP.
EventComparatorUPP NewEventComparatorUPP ( EventComparatorProcPtr userRoutine );
Parameters
- userRoutine
A pointer to your event comparator callback function.
Return Value
The UPP for your callback function.
Discussion
When calling FindSpecificEventInQueue or FlushSpecificEventsFromQueue, you must pass a universal procedure pointer (UPP) to your event comparator instead of a standard procedure pointer.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hNewEventHandlerUPP
Creates an event handler UPP.
EventHandlerUPP NewEventHandlerUPP ( EventHandlerProcPtr userRoutine );
Parameters
- userRoutine
A pointer to your event handler.
Return Value
The UPP for your event handler.
Discussion
When registering your event handler with InstallEventHandler, you must pass a universal procedure pointer (UPP) to your event handler instead of a standard procedure pointer.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hNewEventLoopIdleTimerUPP
Creates an event loop idle timer UPP.
EventLoopIdleTimerUPP NewEventLoopIdleTimerUPP ( EventLoopIdleTimerProcPtr userRoutine );
Parameters
- userRoutine
A pointer to your idle event timer callback function.
Return Value
The UPP for your event loop idle timer callback function.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hNewEventLoopTimerUPP
Creates an event loop timer UPP.
EventLoopTimerUPP NewEventLoopTimerUPP ( EventLoopTimerProcPtr userRoutine );
Parameters
- userRoutine
A pointer to your event timer callback function.
Return Value
The UPP for your event timer callback function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hPopSymbolicHotKeyMode
Removes a hot key mode request from the hot key mode stack.
void PopSymbolicHotKeyMode ( void *inToken );
Parameters
- inToken
The hot key mode token that was returned by a previous call to
PushSymbolicHotKeyMode.
Discussion
If the request is the topmost request on the stack, the hot key mode changes to the next request on the stack. If there are other mode requests on top of this request on the stack, the mode does not change.
Availability
- Available in OS X v10.4 and later.
Declared In
CarbonEvents.hPostEventToQueue
Adds an event to the specified event queue.
OSStatus PostEventToQueue ( EventQueueRef inQueue, EventRef inEvent, EventPriority inPriority );
Parameters
- inQueue
The event queue to post the event onto.
- inEvent
The event to post.
- inPriority
The priority of the event. See “Event Priority Constants” for a list of possible constants to pass.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Posts an event to the queue specified and increments its retain count. This automatically wakes up the event loop of the thread the queue belongs to.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hProcessHICommand
Sends a command to the command chain.
OSStatus ProcessHICommand ( const HICommand *inCommand );
Return Value
A result code. See “Carbon Event Manager Result Codes”
Discussion
ProcessHICommand is a convenience function for sending a “process command” event through the command chain (for example, from menu to user focus to application). The command event is sent initially to either a menu (if the command represents a menu command) or the current user focus. If the function returns eventNotHandledErr, the command was not handled by any element in the chain.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hPushSymbolicHotKeyMode
Sets a new mode for enabling and disabling symbolic hot keys.
void * PushSymbolicHotKeyMode ( OptionBits inOptions );
Parameters
- inOptions
The requested symbolic hot key mode. For details, see “Hot Key Constants.”
Return Value
A token that is passed to PopSymbolicHotKeyMode to remove this mode request when it is no longer needed.
Discussion
The Event Manager maintains a stack of hot key modes that have been requested by calls to this function. The most recently pushed mode is the mode that is currently in use.
Disabling hot keys can significantly affect the usability of Mac OS X. For this reason, applications are allowed to disable hot keys only if the “Enable access for assistive devices” checkbox is checked in the Universal Access preference pane. If this checkbox is not checked when this function is called, the requested hot key mode is pushed onto the mode stack and a valid token is returned but the actual hot key mode is unchanged.
If the frontmost application pushes a new hot key mode that disables any hot keys, the new mode is active only while the application remains the frontmost application. If the application is deactivated or exits without re-enabling hot keys, the hot key mode automatically reverts to the previous mode.
Availability
- Available in OS X v10.4 and later.
Declared In
CarbonEvents.hQuitApplicationEventLoop
Terminates the application event loop.
void QuitApplicationEventLoop ( void );
Discussion
This function is used to quit the RunApplicationEventLoop function. Typically, your application doesn’t need to call this. If your application has the Quit menu item tagged with the kHICommandQuit menu command ID, the toolbox will automatically call this for your application, automatically terminating your event loop. If your application wants to do pre-processing before the event loop exits, it should intercept either the kHICommandQuit menu command, or the kEventAppQuit event.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hQuitAppModalLoopForWindow
Quits the application-modal state for a window.
OSStatus QuitAppModalLoopForWindow ( WindowRef inWindow );
Parameters
- inWindow
The window that is leaving the modal state. See the Window Manager documentation for a description of the
WindowRefdata type.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is used to quit a currently running call to RunAppModalLoopForWindow (that is, it terminates a modal loop). Typically you call this from a handler you have installed on the modal window in question when the user clicks the appropriate button (Ok, Cancel, and so on).
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hQuitEventLoop
Causes a specific event loop to terminate.
OSStatus QuitEventLoop ( EventLoopRef inEventLoop );
Parameters
- inEventLoop
The event loop to terminate.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Usage of this is similar to WakeUpProcess, in that it causes the event loop specified to return immediately (as opposed to timing out). Typically you use this call in conjunction with RunCurrentEventLoop.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hReceiveNextEvent
Waits for the next event of a specified type.
OSStatus ReceiveNextEvent ( ItemCount inNumTypes, const EventTypeSpec *inList, EventTimeout inTimeout, Boolean inPullEvent, EventRef *outEvent );
Parameters
- inNumTypes
The number of event types to wait for (0 if any event should cause this function to return).
- inList
The list of event types we are waiting for (pass
NULLif any event should cause this function to return).- inTimeout
The time to wait before returning (passing
kEventDurationForeveris preferred).- inPullEvent
Pass
truefor this parameter to remove the next matching event from the queue.- outEvent
A pointer to the next event that matches the list passed in. If you passed
truein theinPullEventparameter, the event is owned by you, and you should release it when done.
Return Value
A result indicating whether an event was received, the timeout expired, or the current event loop was quit. See “Carbon Event Manager Result Codes” for possible values.
Discussion
This function tries to fetch the next event of a specified type. If no events in the event queue match, this function will run the current event loop until an event that matches arrives, or the timeout expires. Except for timers firing, your application is blocked waiting for events to arrive when inside this function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRegisterEventHotKey
Registers a global hot key.
OSStatus RegisterEventHotKey ( UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions, EventHotKeyRef *outRef );
Parameters
- inHotKeyCode
The virtual key code of the hot key you want to register.
- inHotKeyModifiers
The keyboard modifiers to look for. In Mac OS X v10.2 and earlier, if you do not specify a modifier key, this function returns
paramErr. In Mac OS X v10.3 and later, passing0does not cause an error.- inHotKeyID
The application-specified hot key ID. You will receive this ID in the
kEventHotKeyPressedevent as the direct object parameter.- inTarget
The target to notify when the hot key is pressed.
- inOptions
Currently unused. You must pass
0.- outRef
On return, a reference to the new hot key. You need this reference if you later wish to unregister it.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function registers a global hot key based on the virtual key code and modifiers you pass in. When the user enters the hot-key combination, a kEventHotKeyPressed event is sent to the target you specified. Only one such combination can exist for the current application (that is, multiple entities in the same application cannot register for the same hot key combination). The same hot key can, however, be registered by multiple applications. This means that multiple applications can potentially be notified when a particular hot key is requested. This might not necessarily be desirable, but it is how it works at present.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hReleaseEvent
Releases, and possibly disposes of, the specified event.
void ReleaseEvent ( EventRef inEvent );
Parameters
- inEvent
The event to release.
Discussion
This function decrements the reference count of an event. If the reference count reaches 0, the event is disposed.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRemoveEventFromQueue
Removes an event from the event queue.
OSStatus RemoveEventFromQueue ( EventQueueRef inQueue, EventRef inEvent );
Parameters
- inQueue
The queue to remove the event from.
- inEvent
The event to remove.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Removes the given event from the queue on which it was posted and decrements its retain count.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRemoveEventHandler
Removes the specified event handler.
OSStatus RemoveEventHandler ( EventHandlerRef inHandlerRef );
Parameters
- inHandlerRef
The handler ref to remove (returned in a call to
InstallEventHandler). After you call this function, the handler reference is considered invalid and can no longer be used.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Removes an event handler from the event target to which it was bound.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRemoveEventLoopTimer
Removes the specified timer.
OSStatus RemoveEventLoopTimer ( EventLoopTimerRef inTimer );
Parameters
- inTimer
The timer to remove.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Removes a timer that was previously installed by a call to InstallEventLoopTimer or InstallEventLoopIdleTimer. You call this function when you are done using a timer.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRemoveEventTypesFromHandler
Removes events from an installed event handler.
OSStatus RemoveEventTypesFromHandler ( EventHandlerRef inHandlerRef, ItemCount inNumTypes, const EventTypeSpec *inList );
Parameters
- inHandlerRef
The event handler to remove the events from.
- inNumTypes
The number of events to remove.
- inList
A pointer to an array of
EventTypeSpecstructures.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
You can use this function dynamically change which events you want your handler to respond to.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRetainEvent
Increments the reference count of an event.
EventRef RetainEvent ( EventRef inEvent );
Parameters
- inEvent
The event to retain.
Return Value
The event reference you passed in the inEvent parameter. A value of NULL indicates an error condition.
Discussion
The RetainEvent function increments an event’s reference count by 1. You can use this function to ensure that an event is never disposed of by another event handler. However, if the event system or some other event handler changes the event, those changes are reflected in your reference. To create a separate, unique copy of an event, use CopyEvent instead.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hRunApplicationEventLoop
Runs the application event loop.
void RunApplicationEventLoop ( void );
Discussion
This function is used as the main event loop for a Carbon Event-based application. Once entered, this function waits for events to arrive and dispatches them to your event handlers automatically.
Note that calling RunApplicationEventLoop also installs the standard application handler, which provides standard handler responses for menu and application events.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hRunAppModalLoopForWindow
Puts the window in an application-modal state.
OSStatus RunAppModalLoopForWindow ( WindowRef inWindow );
Parameters
- inWindow
The window you wish to behave modally. See the Window Manager documentation for a description of the
WindowRefdata type.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is used as a replacement for the Dialog Manager function ModalDialog to drive a Carbon Event-based modal dialog. Once called, this function will not exit until QuitAppModalLoopForWindow is called.
While in the modal state, the standard toolbox dispatcher processes events only for the modal window and any that are above it (that is, closer to the front). This feature allows you to create stacked modal dialogs, if desired.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hRunCurrentEventLoop
Executes the event loop in the current thread.
OSStatus RunCurrentEventLoop ( EventTimeout inTimeout );
Parameters
- inTimeout
The time to wait until returning (can be
kEventDurationForever).
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function “runs” the event loop, returning only if aborted or the timeout specified is reached. The event loop is mostly blocked while in this function, occasionally waking up to fire timers or pick up events. The typical use of this function is to cause the current thread to wait for some operation to complete, most likely on another thread of execution.
Do not assume that this function will not return before the timeout is reached. It can return early in many cases (for example, when WakeUpProcess is called on your process). Always wrap this function in a loop that continues until your program is ready to exit.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hSendEventToEventTarget
Sends an event to the specified event target.
OSStatus SendEventToEventTarget ( EventRef inEvent, EventTargetRef inTarget );
Parameters
- inEvent
The event to send.
- inTarget
The target to send it to.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
If you are creating your own events, you can dispatch them immediately to an event target by calling this function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hSendEventToEventTargetWithOptions
Sends an event to the specified event target with propagation options.
OSStatus SendEventToEventTargetWithOptions ( EventRef inEvent, EventTargetRef inTarget, OptionBits inOptions );
Parameters
- inEvent
The event to send.
- inTarget
The target to send it to.
- inOptions
Options indicating how the event should be propagated. See “Event Target Propagation Options” for a list of possible values.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is identical to SendEventToEventTarget except that you can specify how the event is propagated using options.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hSetEventLoopTimerNextFireTime
Sets the next time that the specified timer will fire.
OSStatus SetEventLoopTimerNextFireTime ( EventLoopTimerRef inTimer, EventTimerInterval inNextFire );
Parameters
- inTimer
The timer whose firing time you want to set.
- inNextFire
The interval from the current time to wait until firing the timer again.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is used to “reset” a timer. It controls the next time the timer fires. This will override any interval you might have set. For example, if you have a timer that fires every second, and you call this function setting the next time to 5 seconds from now, the timer will sleep for 5 seconds, then fire. The timer will then resume its one second interval. This function acts as if you removed the timer and reinstalled it with a new first-fire delay.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hSetEventParameter
Sets a parameter associated with a particular event.
OSStatus SetEventParameter ( EventRef inEvent, EventParamName inName, EventParamType inType, ByteCount inSize, const void *inDataPtr );
Parameters
- inEvent
The event to set the data for.
- inName
The symbolic name of the parameter.
- inType
The symbolic type of the parameter.
- inSize
The size of the parameter data.
- inDataPtr
A pointer to the parameter data.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
When creating events, you may want to specify additional event-related information, such as the mouse location or the window in which the event occurred. To set these you call SetEventParameter, specifying the type and value for the desired parameter.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hSetEventTime
Sets the event time for a given event.
OSStatus SetEventTime ( EventRef inEvent, EventTime inTime );
Parameters
- inEvent
The event in question.
- inTime
The new time.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function allows you to set the time of a given event, if you so desire. In general, you would never use this function, except for those special cases where you reuse an event from time to time instead of creating a new event each time.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hSetMouseCoalescingEnabled
Turns mouse coalescing on or off.
OSStatus SetMouseCoalescingEnabled ( Boolean inNewState, Boolean *outOldState );
Parameters
- inNewState
Pass
trueto turn mouse coalescing on,falseotherwise.- outOldState
A Boolean value indicating the previous mouse coalescing state (that is, before you called this function to set it). You can use this value if you want to save the previous state for later restoration. If you don’t need this state information, pass
NULL.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
See IsMouseCoalescingEnabled for a definition of mouse coalescing.
Availability
- Available in OS X v10.1 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hTrackMouseLocation
Tracks the mouse, blocking your application when there is no activity.
OSStatus TrackMouseLocation ( GrafPtr inPort, Point *outPt, MouseTrackingResult *outResult );
Parameters
- inPort
The graphics port to consider for mouse coordinates. You can pass
NULLfor this parameter to indicate the current port. The mouse location is returned in terms of local coordinates of this port. Pass-1for this port to obtain global coordinates instead.See the QuickDraw Manager documentation for a description of the
GrafPtrdata type.- outPt
On exit, a pointer to the mouse location from the last mouse event that caused this function to exit.
- outResult
On exit, a pointer to a value representing what kind of event was received that cause the function to exit, such as
kMouseTrackingMouseReleased.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Once entered, this function waits for certain mouse events (move, mouse down, mouse up). When one of these events occurs, the function returns and tells the caller what happened and where the mouse is currently located. While there is no activity, the current event loop is run, effectively blocking the current thread (save for any timers that fire). This helps to minimize CPU usage when there is nothing going on.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hTrackMouseLocationWithOptions
Tracks the mouse with additional options.
OSStatus TrackMouseLocationWithOptions ( GrafPtr inPort, OptionBits inOptions, EventTimeout inTimeout, Point *outPt, UInt32 *outModifiers, MouseTrackingResult *outResult );
Parameters
- inPort
The graphics port (
GrafPort) to consider for mouse coordinates. You can passNULLfor this parameter to indicate the current port. The mouse location is returned in global coordinates. Pass-1for this port to obtain global coordinates instead.See the QuickDraw Manager documentation for a description of the
GrafPtrdata type.- inOptions
The only option supported by this function at present is the option to have the toolbox leave mouse up events in the queue, rather than pulling them (which is the default). See “Mouse Tracking Option Constant” for more information.
- inTimeout
The amount of time to wait for an event. If no events arrive within this time,
kMouseTrackingTimedOutis returned inoutResult.- outPt
On return, a pointer to the mouse location from the last mouse event that caused this function to exit. If a timeout or key modifiers changed event caused this function to exit, the current mouse position at the time is returned.
- outModifiers
On return, a pointer to the most recent state of the keyboard modifiers.
- outResult
On return, a pointer to a value indicating the kind of event that caused the function to exit, such as
kMouseTrackingMouseReleased.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Once entered, this function waits for certain mouse events (move, mouse down, mouse up). When one of these events occurs, the function returns and tells the caller what happened and where the mouse is currently located. While there is no activity, the current event loop is run, effectively blocking the current thread (save for any timers that fire). This helps to minimize CPU usage when there is nothing going on.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hTrackMouseRegion
Tracks the mouse within a region.
OSStatus TrackMouseRegion ( GrafPtr inPort, RgnHandle inRegion, Boolean *ioWasInRgn, MouseTrackingResult *outResult );
Parameters
- inPort
The graphics port to consider for mouse coordinates. You can pass
NULLfor this parameter to indicate the current port. Pass-1for this port to obtain global coordinates instead.See the QuickDraw Manager documentation for a description of the
GrafPtrdata type.- inRegion
The region to consider. This should be in the coordinates of the port you passed to
inPort. See the QuickDraw Manager documentation for a description of theRgnHandledata type.- ioWasInRgn
On entering the region, this parameter should be set to
trueif the mouse is currently inside the region passed ininRegion, orfalseif the mouse is currently outside the region. On exit, this parameter is updated to reflect the current reality. For example, if theoutResultparameter returnskMouseTrackingMouseExited,ioWasInRgnwill be set tofalsewhen this function exits. Because it is updated from within, you should only need to set this yourself before the first call to this function in your tracking loop.- outResult
On exit, a pointer to a value indicating the kind of event that caused the function to exit, such as
kMouseTrackingMouseEntered.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
This function is largely identical to TrackMouseLocation. The difference between TrackMouseLocation and TrackMouseRegion is that TrackMouseRegion only returns when the mouse enters or exits a specified region that you pass in to the function, as opposed to whenever the mouse moves (it also returns for mouse up/down events). This is useful if you don’t need to know intermediate mouse events, but rather just if the mouse enters or leaves an area.
Note that in some cases you may prefer to register one or more special mouse tracking regions and receive events when the mouse enters or exits the region. However, this alternative method does not automatically inform you about mouse up and mouse down actions. See CreateMouseTrackingRegion for more details.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hUnregisterEventHotKey
Unregisters a global hot key.
OSStatus UnregisterEventHotKey ( EventHotKeyRef inHotKey );
Parameters
- inHotKey
The event hot key reference of the hot key you want to unregister.
Return Value
A result code. See “Carbon Event Manager Result Codes.”
Discussion
Unregisters a global hot key that was previously registered with the function RegisterEventHotKey. You do not need to unregister a hot key when your application terminates; the system takes care of that for you. You can use this function if the user changes a hot key for something in your application—you would unregister the previous key and register your new key.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hCallbacks
EventComparatorProcPtr
Defines the format of your event comparator callback function.
typedef Boolean (*EventComparatorProcPtr) ( EventRef inEvent, void * inCompareData );
If you name your function MyEventComparatorProc, you would declare it like this:
Boolean MyEventComparatorProc ( EventRef inEvent, void * inCompareData );
Parameters
- inEvent
The event to compare.
- inCompareData
The data you passed to
FindSpecificEventInQueueorFlushSpecificEventsFromQueue.
Return Value
A Boolean value indicating whether the event matches (true) or not (false).
Discussion
You use this callback function when searching the event queue using functions such as FindSpecificEventInQueue.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventHandlerProcPtr
Defines the format of your event handler.
typedef OSStatus (*EventHandlerProcPtr) ( EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData );
If you name your function MyEventHandlerProc, you would declare it like this:
OSStatus MyEventHandlerProc ( EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData );
Parameters
- inHandlerCallRef
A reference to the current handler call chain. This is passed to your handler so that you can call
CallNextEventHandlerif you need to.- inEvent
The event that triggered this call.
- inUserData
The application-specific data you passed in to
InstallEventHandler.
Return Value
A result code. See “Carbon Event Manager Result Codes.” Returning noErr indicates you handled the event. Returning eventNotHandledErr indicates you did not handle the event and perhaps other handlers in the calling chain should take action.
Discussion
Callback to install on an event target.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventLoopIdleTimerProcPtr
Defines the format of your idle timer callback function.
typedef void (*EventLoopIdleTimerProcPtr) ( EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void * inUserData );
If you name your function MyEventLoopTimerProc, you would declare it like this:
void MyEventLoopTimerProc ( EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void * inUserData );
Parameters
- inTimer
The timer that fired.
- inState
The state of the idle period. See “Idle Timer Event Constants” for a list of possible constants you can receive.
- inUserData
The application-specific data you passed into
InstallEventLoopIdleTimer.
Discussion
Called when an idle timer fires.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hEventLoopTimerProcPtr
Defines the format of your event loop timer callback function.
typedef void (*EventLoopTimerProcPtr) ( EventLoopTimerRef inTimer, void * inUserData );
If you name your function MyEventLoopTimerProc, you would declare it like this:
void MyEventLoopTimerProc ( EventLoopTimerRef inTimer, void * inUserData );
Parameters
- inTimer
The timer that fired.
- inUserData
The data you passed into
InstallEventLoopTimer.
Discussion
Called when a timer fires.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hData Types
EventClassID
Represents an event class ID.
typedef UInt32 EventClassID;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hEventComparatorUPP
Represents a universal procedure pointer to an event comparator callback function.
typedef EventComparatorProcPtr EventComparatorUPP
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventHandlerCallRef
Indicates the next handler in the event handler calling hierarchy.
typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef;
Discussion
This structure is passed to your event handler, which can then choose to pass control to the next handler in the calling hierarchy (such as a standard event handler). Doing so is a convenient way to add pre- or post-processing to the standard event handler. See the CallNextEventHandler function for more information.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventHandlerUPP
Represents a universal procedure pointer for an event handler callback function.
typedef EventHandlerProcPtr EventHandlerUPP;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventLoopTimerUPP
Represents a universal procedure pointer for an event timer callback function.
typedef EventLoopTimerProcPtr EventLoopTimerUPP;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventLoopIdleTimerUPP
Represents a universal procedure pointer for an idle event timer callback function.
typedef EventLoopIdleTimerProcPtr EventLoopIdleTimerUPP;
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hEventHandlerRef
Represents an installed event handler.
typedef struct OpaqueEventHandlerRef * EventHandlerRef;
Discussion
You receive an event handler reference when you install your handler using InstallEventHandler. You can use this reference when calling functions such as RemoveEventHandler and AddEventTypesToHandler.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventHotKeyID
Represents the ID of a global hot key.
struct EventHotKeyID {
OSType signature;
UInt32 id;
};
typedef struct EventHotKeyID EventHotKeyID;
Discussion
You register a hot key using the RegisterEventHotKey function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hEventHotKeyRef
Represents a registered global hot key.
typedef struct OpaqueEventHotKeyRef * EventHotKeyRef;
Discussion
You register a hot key using the RegisterEventHotKey function.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hEventLoopIdleTimerMessage
Represents an idle timer message.
typedef UInt16 EventLoopIdleTimerMessage;
Discussion
Sent to idle timer callback functions to indicate the current idle status. See “Idle Timer Event Constants” for a list of possible values.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEventsCore.hEventLoopRef
Represents an event loop.
typedef struct OpaqueEventLoopRef * EventLoopRef;
Discussion
The EventLoopRef type 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 or InstallEventLoopIdleTimer. 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 through calls to functions like ReceiveNextEvent, RunApplicationEventLoop, or even the Classic Event Manager function WaitNextEvent. It can also be run explicitly through a call to RunCurrentEventLoop. Each preemptive thread can have an event loop. Cooperative threads share the main thread’s event loop.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventLoopTimerRef
Represents an installed event timer.
typedef struct __EventLoopTimer * EventLoopTimerRef;
Discussion
The EventLoopTimerRef type represents a timer function that is called either once or at regular intervals. See InstallEventLoopTimer and InstallEventLoopIdleTimer for more information about event timers.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventParamName
Represents an event parameter constant.
typedef OSType EventParamName;
Discussion
You specify an event parameter name when calling GetEventParameter or SetEventParameter. Parameter names indicate what kind of event parameter you want to set or obtain (such as kEventParamDirectObject). For specific types, see the tables of event parameters and types associated with each class of events (for example, Table 8).
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventParamType
Represents an event parameter type constant.
typedef OSType EventParamType;
Discussion
You specify an event parameter type when calling GetEventParameter or SetEventParameter. Event parameter types indicate the data type of the parameter you want to set or obtain (such as typeBoolean). For specific types, see the tables of event parameters and types associated with each class of events (for example, Table 11).
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventQueueRef
Represents an event queue.
typedef struct OpaqueEventQueueRef * EventQueueRef;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventRef
Represents an opaque data structure that identifies individual events.
typedef struct OpaqueEventRef * EventRef;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventTargetRef
Represents an event target (such as a window or control).
typedef struct OpaqueEventTargetRef * EventTargetRef;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventTime
Represents a time value in seconds. An absolute EventTime value is seconds since boot time.
typedef double EventTime;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventTimeout
Represents a timeout interval, in seconds.
typedef EventTime EventTimeout;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventTimerInterval
Specifies the period of an event timer, in seconds.
typedef EventTime EventTimerInterval;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hEventType
Represents an event type.
typedef UInt32 EventType;
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hEventTypeSpec
Describes the class and kind of an event.
struct EventTypeSpec {
UInt32 eventClass;
UInt32 eventKind;
};
typedef struct EventTypeSpec EventTypeSpec;
Discussion
This structure is used to specify an event. Typically, you pass a static array of EventTypeSpec structures into functions such as InstallEventHandler, as well as functions such as FlushEventsMatchingListFromQueue.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEventsCore.hHICommand
Represents a command event; this structure has been superseded by the HICommandExtended structure.
struct HICommand {
UInt32 attributes
UInt32 commandID
struct {
MenuRef menuRef;
MenuItemIndex menuItemIndex;
} menu;
};
typedef struct HICommand HICommand;
Fields
attributesAttributes of the command event.
commandIDThe command ID of the command event.
menuRefA reference to the menu containing the HICommand.
menuItemIndexThe index number of the menu item containing the HICommand.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hHICommandExtended
Represents an extended command event.
struct HICommandExtended {
UInt32 attributes;
UInt32 commandID;
union {
controlRef control;
windowRef window;
struct {
MenuRef menuRef;
MenuItemIndex menuItemIndex;
} menu;
} source;
};
typedef struct HICommandExtended HICommandExtended;
Fields
attributesAttributes of the command event. The value of this field (indicating whether the source of the command event is a control, window, or menu) determines what reference is stored in the union. See “Command Event Source Constants” for a list of possible values.
commandIDThe command ID of the command event.
controlRefThe control that produced the command event.
windowRefThe window that produced the command event.
menuRefA reference to the menu containing the command event.
menuItemIndexThe index number of the menu item containing the command event.
Discussion
The HICommandExtended structure was introduced in Mac OS X v10.2 and CarbonLib 1.6. Because the HICommand and HICommandExtended structures are exactly the same size and have the same fields at the same offsets, you can use an HICommandExtended structure at runtime while running on any version of CarbonLib or Mac OS X. The only difference is that the HICommandExtended structure has a union that allows you to get type-safe access to the source object. The originator of the command determines whether the structure actually contains a ControlRef, WindowRef, MenuRef, or nothing at all. You can determine what is in the command by checking the attributes field.
For example, in Mac OS X v10.2 and later, when a push button is clicked, the Control Manager sends a command event containing the push button’s command ID, sets the kHICommandFromControl bit in the attributes field, and stores the button’s ControlRef in the source.control field. In Mac OS X v10.0 and v10.1, the same command event is sent, but the kHICommandFromControl, kHICommandFromMenu, and kHICommandFromWindow attributes are not set, and the source.controlRef, source.menu.menuRef and source.windowRef fields are not initialized, respectively. Your code can use an HICommandExtended structure when running on Mac OS X v10.0 and v10.1 as long as it first checks the kHICommandFromControl, kHICommandFromMenu, and kHICommandFromWindow attributes before accessing the source.control, menu.control, and window.control fields.
Availability
- Available in OS X v10.2 and later.
Declared In
CarbonEvents.hMouseTrackingRef
Represents a mouse tracking region
typedef struct OpaqueMouseTrackingRef * MouseTrackingRef;
Discussion
Use CreateMouseTrackingRegion to create a mouse tracking region.
Availability
- Available in OS X v10.2 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hMouseTrackingRegionID
Represents a mouse tracking region identifier.
struct MouseTrackingRegionID {
OSType signature;
SInt32 id;
};
typedef struct MouseTrackingRegionID MouseTrackingRegionID;
Fields
signatureA four-character code (such as
'moof')that uniquely identifies the application that owns this mouse tracking region.idAn integer that identifies the mouse tracking region in this application.
Discussion
Each application can register multiple mouse tracking regions as long as each region has a unique ID. Use CreateMouseTrackingRegion to create a mouse tracking region.
Availability
- Available in OS X v10.2 and later.
- Not available to 64-bit applications.
Declared In
CarbonEvents.hTabletPointRec
Defines a tablet point structure.
struct TabletPointRec {
SInt32 absX;
SInt32 absY;
SInt32 absZ;
UInt16 buttons;
UInt16 pressure;
SInt16 tiltX;
SInt16 tiltY;
UInt16 rotation;
SInt16 tangentialPressure;
UInt16 deviceID;
SInt16 vendor1;
SInt16 vendor2;
SInt16 vendor3;
};
typedef struct TabletPointRec TabletPointRec;
typedef TabletPointRec TabletPointerRec;
Fields
absXThe x-coordinate of the pointer, in tablet space (at full tablet resolution).
absYThe y-coordinate of the pointer, in tablet space (at full tablet resolution).
absZThe z-coordinate of the pointer, in tablet space (at full tablet resolution).
buttonsThe buttons that are pressed. This integer is interpreted as a bit field, with bit 0 indicating the first button, bit 1 the second button, and so on. A value of
1indicates that the button is down.pressureThe scaled pressure value. The pressure value is in the range 0 to 65535.
tiltXThe scaled tilt x value. The tilt value is in the range -32767 to 32767.
tiltYThe scaled tilt y value. The tilt value is in the range -32767 to 32767.
rotationThe device rotation as a fixed-point value in a 10.6 format.
tangentialPressureThe tangential pressure on the device. This pressure is in the range -32767 to 32767.
deviceIDA unique system-assigned device ID. This ID matches the device ID you receive for the
kEventTabletProximityevent.vendor1A vendor-defined value.
vendor2A vendor-defined value.
vendor3A vendor-defined value.
Discussion
You receive this structure in the kEventParamTabletPointRec parameter for the kEventTabletPoint event.
Availability
- Available in OS X v10.1 and later.
Declared In
CarbonEvents.hTabletProximityRec
Defines a tablet proximity structure.
struct TabletProximityRec {
UInt16 vendorID;
UInt16 tabletID;
UInt16 pointerID;
UInt16 deviceID;
UInt16 systemTabletID;
UInt16 vendorPointerType;
UInt32 pointerSerialNumber;
UInt64 uniqueID;
UInt32 capabilityMask;
UInt8 pointerType;
UInt8 enterProximity;
};
typedef struct TabletProximityRec TabletProximityRec;
Fields
vendorIDA vendor-defined ID. This value is typically the USB vendor ID.
tabletIDA vendor-defined ID for the tablet. This value is typically the USB product ID for the tablet.
pointerIDA vendor-defined ID for the pointing device (for example, a pen).
deviceIDA unique system-assigned device ID. This ID matches the device ID you receive for the
kEventTabletPointevent.systemTabletIDA system-assigned unique tablet ID.
vendorPointerTypeA vendor-defined pointer type.
pointerSerialNumberA vendor-defined serial number for the pointing device.
uniqueIDA vendor-defined ID for this pointer.
capabilityMaskA bit mask representing the capabilities of this device.
pointerTypeThe type of pointing device.
enterProximityThe proximity value. A nonzero value indicates that the pointer is entering the tablet proximity; zero indicates that it is leaving.
Discussion
You receive this structure in the kEventParamTabletProximityRec parameter for the kEventTabletProximity event.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hToolboxObjectClassRef
Represents a toolbox object class.
typedef struct OpaqueToolboxObjectClassRef * ToolboxObjectClassRef;
Discussion
Typically you use toolbox object classes to specify custom user interface elements. See RegisterToolboxObjectClass for more information.
Availability
- Available in OS X v10.0 and later.
Declared In
CarbonEvents.hConstants
Basic Event Constants
Event Class Constants
Define constants for specifying event classes.
typedef UInt32 EventClass;
enum {
kEventClassMouse = 'mous',
kEventClassKeyboard = 'keyb',
kEventClassTextInput = 'text',
kEventClassApplication = 'appl',
kEventClassAppleEvent = 'eppc',
kEventClassMenu = 'menu',
kEventClassWindow = 'wind',
kEventClassControl = 'cntl',
kEventClassCommand = 'cmds',
kEventClassTablet = 'tblt',
kEventClassVolume = 'vol ',
kEventClassAppearance = 'appm',
kEventClassService = 'serv',
kEventClassToolbar = 'tbar',
kEventClassToolbarItem = 'tbit',
kEventClassToolbarItemView = 'tbiv',
kEventClassAccessibility = 'acce'.
kEventClassSystem = 'macs',
kEventClassInk = 'ink ',
kEventClassTSMDocumentAccess = 'tdac'
};
Constants
kEventClassMouseEvents related to the mouse (mouse down/up/moved).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassKeyboardEvents related to the keyboard.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassTextInputEvents related to text input (by keyboard or by input method).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassApplicationApplication-level events (launch, quit, and so on).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassAppleEventApple Events.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassMenuMenu-related events.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassWindowWindow-related events.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassControlControl-related events.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassCommandCommand events (HICommands).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassTabletEvents related to tablet input.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassVolumeEvents related to File Manager volumes.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventClassAppearanceEvents related to the Appearance Manager.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventClassServiceEvents related to the Services Manager.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventClassToolbarEvents related to the toolbar (not the toolbar window class).
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventClassToolbarItemEvents related to toolbar items.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventClassToolbarItemViewEvents related to toolbar item views.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventClassAccessibilityEvents related to application accessibility features.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventClassSystemEvents related to the system.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventClassInkEvents related to ink.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventClassTSMDocumentAccessEvents related to Text Services Manager document access.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Discussion
Event classes specify broad categories of events, grouped according to the object they are associated with. Within an event class are specific event types.
Event Attributes
Define constants for special attributes of an event.
typedef UInt32 EventAttributes;
enum {
kEventAttributeNone = 0,
kEventAttributeUserEvent = (1 << 0),
kEventAttributeMonitored= 1 << 3
};
Constants
kEventAttributeNoneNo attributes.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventAttributeUserEventAn event generated in response to a user action.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventAttributeMonitoredAn event that was not originally targeted to this process but has been provided to this process because an event handler for this event type has been installed on the event monitoring target. The event dispatcher sends events with this attribute directly to the event monitor target.
Available in OS X v10.3 and later.
Declared in
CarbonEventsCore.h.
Discussion
You use these attributes only if you are creating your own events.
Event Priority Constants
Define event priority constants.
typedef SInt16 EventPriority;
enum {
kEventPriorityLow = 0,
kEventPriorityStandard = 1,
kEventPriorityHigh = 2
};
Constants
kEventPriorityLowLowest priority. Currently only window update events are posted at this priority.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventPriorityStandardNormal priority of events. Most events are standard priority.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventPriorityHighHighest priority.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.
Discussion
These values define the relative priority of an event, and are used when posting events with PostEventToQueue. In general events are pulled from the queue in order of first posted to last posted. These priorities are a way to alter that behavior when posting events. You can post a standard priority event and then a high priority event, and the high priority event will be pulled from the queue first.
Event Target Propagation Options
Define options for the SendEventToEventTargetWithOptions function.
enum {
kEventTargetDontPropagate = (1 << 0),
kEventTargetSendToAllHandlers = (1 << 1)
};
Constants
kEventTargetDontPropagateDo not propagate this event to any other event target. That is, even if the handler returns
eventNotHandledErr, the event is not propagated up the handler chain. When passed an event sent with this option,CallNextEventHandleronly calls other event handlers installed on the current event target; it does not propagate the event to other event targets.Available in OS X v10.2 and later.
Declared in
CarbonEventsCore.h.kEventTargetSendToAllHandlersSend this event to all event targets in the handler chain, regardless of any handler’s return value. For example, if sent to a control, after returning, the event is sent to the owning window and then to the application. Note that the Carbon Event Manager keeps track of the strongest result code when progressing up the handler chain. That is, if the first handler returns
noErr, and the second handler returnseventNotHandledErr, the result returned isnoErr.Available in OS X v10.2 and later.
Declared in
CarbonEventsCore.h.
Event Queue Constants
Define constants for specifying how events should be handled on the queue.
enum {
kEventLeaveInQueue = false,
kEventRemoveFromQueue = true
};
Constants
kEventLeaveInQueueLeave the event on the queue after examining.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventRemoveFromQueueRemove the event from the queue after examining.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.
Discussion
When calling a function such as ReceiveNextEvent, you can specify whether to leave the event on the queue (peeking at it to determine its class, type, and so on), or to pull it before dispatching it to an event handler.
Direct Object Parameter
Define the direct object parameter.
enum {
kEventParamDirectObject = '----'
};
Constants
kEventParamDirectObjectType varies depending on event.
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.
Discussion
The direct object parameter is usable for a wide variety of events. It defines the “object the event acted upon or within.” For example, for window events, the direct object parameter returns a reference (that is a WindowRef) to the window in which the event occurred.
Event Target Parameter
Define constants for a special event target parameter and its type, that you can set for any created event.
enum {
kEventParamPostTarget = 'ptrg',
typeEventTargetRef = 'etrg'
};
Constants
kEventParamPostTargetSpecifies the target the event should be sent to. Instead of sending an event directly to a given target, you can set this parameter and post the event onto the event queue.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.typeEventTargetRefThe parameter type for
kEventParamPostTarget.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Object Reference Parameters and Types
Define constants for parameters that specify various objects and their types.
enum {
kEventParamWindowRef = 'wind',
kEventParamGrafPort = 'graf',
kEventParamDragRef = 'drag',
kEventParamMenuRef = 'menu',
kEventParamEventRef = 'evnt',
kEventParamControlRef = 'ctrl',
kEventParamRgnHandle = 'rgnh',
kEventParamEnabled = 'enab',
kEventParamDimensions = 'dims',
kEventParamBounds = 'boun',
kEventParamAvailableBounds = 'avlb',
kEventParamAEEventID = keyAEEventID,
kEventParamAEEventClass = keyAEEventClass,
kEventParamCGContextRef = 'cntx',
kEventParamDeviceDepth = 'devd',
kEventParamDeviceColor = 'devc',
kEventParamMutableArray = 'marr',
kEventParamResult = 'ansr',
kEventParamMinimumSize = 'mnsz',
kEventParamMaximumSize = 'mxsz',
kEventParamAttributes = 'attr',
kEventParamReason = 'why?',
kEventParamTransactionID = 'trns',
kEventParamGDevice = 'gdev',
kEventParamIndex = 'indx',
kEventParamUserData = 'usrd',
kEventParamShape = 'shap',
typeWindowRef = 'wind',
typeGrafPtr = 'graf',
typeGWorldPtr = 'gwld',
typeDragRef = 'drag',
typeMenuRef = 'menu',
typeControlRef = 'ctrl',
typeCollection = 'cltn',
typeQDRgnHandle = 'rgnh',
typeOSStatus = 'osst',
typeCFIndex = 'cfix',
typeCGContextRef = 'cntx',
typeHIPoint = 'hipt',
typeHISize = 'hisz',
typeHIRect = 'hirc',
typeHIShapeRef = 'shap',
typeVoidPtr = 'void',
typeGDHandle = 'gdev'
};
Constants
kEventParamWindowRefA window reference. (typeWindowRef)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamGrafPorttypeGrafPtr
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamDragReftypeDragRef
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.kEventParamMenuReftypeMenuRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamEventReftypeEventRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlReftypeControlRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamRgnHandletypeQDRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamEnabledtypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamDimensionstypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamBoundstypeQDRectangle
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamAvailableBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamAEEventIDtypeType
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamAEEventClasstypeType
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamCGContextReftypeCGContextRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamDeviceDepthtypeShortInteger
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamDeviceColortypeBoolean
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamMutableArraytypeCFMutableArrayRef
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamResultAny type, depending on the event
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamMinimumSizetypeHISize
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamMaximumSizetypeHISize
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamAttributestypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamReasontypeUInt32
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTransactionIDtypeUInt32
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamGDevicetypeGDHandle
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamIndextypeCFIndex
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamUserDatatypeVoidPtr
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamShapetypeHIShapeRef
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.typeWindowRefWindowRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeGrafPtrCGrafPtr
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeGWorldPtrGWorldPtr
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeDragRefDragRef
Available in OS X v10.0 and later.
Declared in
CarbonEventsCore.h.typeMenuRefMenuRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeControlRefControlRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeCollectionCollection
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeQDRgnHandleRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeOSStatusOSStatus
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeCFIndexCFIndex
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.typeCGContextRefCGContextRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeHIPointHIPoint
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.typeHISizeHISize
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.typeHIRectHIRect
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.typeHIShapeRefHIShapeRef
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.typeVoidPtrVoid
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.typeGDHandleGDHandle
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Discussion
You specify these parameters to obtain references to various objects such as windows, controls, graphics ports, and so on. See the various event kinds to determine the parameters available for each event. For example, Table 8 in “Mouse Events” lists the various parameters used in mouse events.
Core Foundation Object Types
Define type constants for Carbon event parameters that refer to Core Foundation objects.
enum {
typeCFAttributedStringRef = 'cfas',
typeCFMutableAttributedStringRef = 'cfaa',
typeCFStringRef = 'cfst',
typeCFMutableStringRef = 'cfms',
typeCFArrayRef = 'cfar',
typeCFMutableArrayRef = 'cfma',
typeCFDictionaryRef = 'cfdc',
typeCFMutableDictionaryRef = 'cfmd',
typeCFNumberRef = 'cfnb',
typeCFBooleanRef = 'cftf',
typeCFTypeRef = 'cfty'
};
Constants
typeCFAttributedStringRefA Core Foundation attributed string.
Available in OS X v10.5 and later.
Declared in
AEDataModel.h.typeCFMutableAttributedStringRefA Core Foundation mutable attributed string.
Available in OS X v10.5 and later.
Declared in
AEDataModel.h.typeCFStringRefA Core Foundation string.
Available in OS X v10.1 and later.
Declared in
AEDataModel.h.typeCFMutableStringRefA Core Foundation mutable string.
Available in OS X v10.2 and later.
Declared in
AEDataModel.h.typeCFArrayRefA Core Foundation array.
Available in OS X v10.3 and later.
Declared in
AEDataModel.h.typeCFMutableArrayRefA Core Foundation mutable array.
Available in OS X v10.1 and later.
Declared in
AEDataModel.h.typeCFDictionaryRefA Core Foundation dictionary.
Available in OS X v10.3 and later.
Declared in
AEDataModel.h.typeCFMutableDictionaryRefA Core Foundation mutable dictionary.
Available in OS X v10.3 and later.
Declared in
AEDataModel.h.typeCFNumberRefA Core Foundation number.
Available in OS X v10.5 and later.
Declared in
AEDataModel.h.typeCFBooleanRefA Core Foundation Boolean value.
Available in OS X v10.5 and later.
Declared in
AEDataModel.h.typeCFTypeRefA Core Foundation type.
Available in OS X v10.2 and later.
Declared in
AEDataModel.h.
Declared In
AEDataModel.hApple Event Constants
AppleEvent Constant
Define a constant related to events from kEventClassAppleEvent.
enum {
kEventAppleEvent = 1
};
Constants
kEventAppleEventAn AppleEvent event was received.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
The standard application handler automatically calls the Apple Event Manager function AEProcessAppleEvent to handle Apple events.
Table 1 shows the parameter associated with AppleEvent events.
Event kind |
Parameter name |
Parameter type |
|
|
|
Deprecated AppleEvent Event Constants
Define constants for older names for AppleEvent event constants.
enum {
kEventClassEPPC = kEventClassAppleEvent,
kEventHighLevelEvent = kEventAppleEvent
};
Constants
kEventClassEPPCEquivalent to
kEventClassAppleEvent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventHighLevelEventEquivalent to
kEventAppleEvent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Appearance Manager Event Constants
Appearance Manager Events
Define a constant related to events from kEventClassAppearance.
enum {
kEventAppearanceScrollBarVariantChanged = 1
};
Constants
kEventAppearanceScrollBarVariantChangedThe scroll bar variant has changed.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.
Appearance Manager Event Parameter
Define a constant for the parameter to Appearance Manager events.
enum {
kEventParamNewScrollBarVariant = 'nsbv'
};
Constants
kEventParamNewScrollBarVarianttypeShortInteger
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.
Application Event Constants
Application Event Constants
Define constants related to events from kEventClassApplication.
enum {
kEventAppActivated = 1,
kEventAppDeactivated = 2,
kEventAppQuit = 3,
kEventAppLaunchNotification = 4,
kEventAppLaunched = 5,
kEventAppTerminated = 6,
kEventAppFrontSwitched = 7,
kEventAppFocusMenuBar = 8,
kEventAppFocusNextDocumentWindow = 9,
kEventAppFocusNextFloatingWindow = 10,
kEventAppFocusToolbar = 11,
kEventAppFocusDrawer = 12,
kEventAppGetDockTileMenu = 20,
kEventAppIsEventInInstantMouser = 104,
kEventAppHidden = 107,
kEventAppShown = 108,
kEventAppSystemUIModeChanged = 109,
kEventAppAvailableWindowBoundsChanged = 110,
kEventAppActiveWindowChanged = 111
};
Constants
kEventAppActivatedThe application was activated (resumed, in old parlance).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppDeactivatedThe application was deactivated (suspended, in old parlance).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppQuitThe application is quitting.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppLaunchNotificationResponse to asynchronous application launch.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppLaunchedSome other application was launched. (CarbonLib 1.3 or later)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppTerminatedSome other application was terminated. (CarbonLib 1.3 or later)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppFrontSwitchedThe frontmost application has changed. (CarbonLib 1.3 or later)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventAppFocusMenuBarRequest to switch the keyboard focus to the menu bar. The Carbon Event Manager handles this event by default.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppFocusNextDocumentWindowRequest to shift keyboard focus to the next or previous document window (depending on the state of the Shift key). If there are no more document windows in the current process, focus should shift to the document window in the next (or previous) process.
If something other than a document window currently has keyboard focus, you should shift focus to the frontmost document window without changing the ordering of the windows.
If the document window does not have a focused area, you should set the focus to the main control within the window.
The Carbon Event Manager handles this event by default; if you handle this event, you should only check if the user focus is somewhere other than a document window, and if so, set the focus on the active document window. If the focus is already on a document window, your handler should always return
eventNotHandledErrso that the default handler can rotate to the next window across all processes.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppFocusNextFloatingWindowRequest to shift keyboard focus to the next or previous floating window (depending on the state of the Shift key).
If something other than a floating window currently has keyboard focus, you should shift focus to the frontmost floating window without changing the ordering of the windows.
If the floating window does not have a focused area, you should set the focus to the main control within the window.
The default behavior for this event is to send a
kEventCommandProcessevent containingkHICommandRotateFloatingWindowsForwardorkHICommandRotateFloatingWindowsBackward.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppFocusToolbarRequest to shift keyboard focus to the toolbar.
The default behavior for this event is to move the keyboard focus to the first item in the toolbar (assuming you are using the standard toolbar).
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppFocusDrawerRequest to shift keyboard focus to the drawer in the focused window.
The default behavior for this event is to move the focus to the first control in the drawer in the focused window if a drawer is present. If multiple drawers are present, focus is moved in clockwise order from one drawer to the next, starting with the top drawer, if any. If the modifiers parameter contains the shift key, focus is moved in reverse (counterclockwise) order.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventAppGetDockTileMenuRequest to display a pop-up menu by the application’s dock tile. You should return the menu reference of the menu to display in the
kEventParamMenuRefparameter. The sender of this event releases this menu after the Dock displays it, so if you supply a permanently allocated menu reference, you should call the Menu Manager functionRetainMenuon it before returning from your handler.The default behavior for this event is to return the menu (if any) supplied by the
SetApplicationDockTileMenufunction (described in the Dock Manager Reference). Note that for most functions, it’s easier to set a menu usingSetApplicationDockTileMenurather than installing a handler for this event.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventAppIsEventInInstantMouserThe given event’s global mouse location is over an “instant mousing” area. An instant mousing area is an area where a mouse down should not generate ink but should be interpreted as a click.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventAppHiddenThe application was hidden.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppShownThe application was shown.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppSystemUIModeChangedThe system user interface mode of the frontmost application has changed.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventAppAvailableWindowBoundsChangedThe available window positioning bounds have changed. This event is currently sent when the Dock has changed position or size and when the display configuration has changed. A separate copy of this event is sent to each affected GDevice.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventAppActiveWindowChangedThe active window in the current process has changed. The Window Manager uses
ActiveNonFloatingWindowto track the active window. WhenSelectWindowis called on a window, that window is made the new active window. At that time, the Window Manager also posts akEventAppActiveWindowChangedevent to the main event queue.If more than one window is activated sequentially before the event loop is run, a single
kEventAppActiveWindowChangedevent is left in the event queue. ItsPreviousActiveWindowparameter will be the window that was originally active, and itsCurrentActiveWindowparameter will be the window that was finally active.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Discussion
You can pass any of these constants when registering an event handler. You can also pass these constants to the CreateEvent function to specify the type of application event you want to create.
Table 2 shows the event parameters associated with application events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
None |
|
|
None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
None |
|
|
None |
|
|
|
|
Application Event Parameters
Define constants for parameters to application events.
enum {
kEventParamProcessID = 'psn ',
kEventParamLaunchRefCon = 'lref',
kEventParamLaunchErr = 'err ',
kEventParamSystemUIMode = 'uimd'
};
Constants
kEventParamProcessIDtypeProcessSerialNumber
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamLaunchRefContypeWildcard
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamLaunchErrtypeOSStatus
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamSystemUIModetypeUInt32
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Command Events
Command Event Constants
Define constants related to events from kEventClassCommand.
enum {
kEventProcessCommand = 1,
kEventCommandProcess = 1,
kEventCommandUpdateStatus = 2
};
Constants
kEventProcessCommandA command has been invoked and the application should handle it. This event is sent when the user chooses a menu item or when a control with a command is pressed. Some senders of this event will also include the modifier keys that were pressed by the user when the command was invoked, but this parameter is optional.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventCommandProcessSame as
kEventProcessCommand.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventCommandUpdateStatusSent when updates related to the command event may be required. When you receive this event, you should update the necessary user interface elements in your application to reflect the current status of the command. For example, if the command has the
kHICommandFromMenubit set, you should update the menu item state, text, and so on, to reflect the current state of your application.Note that the standard handler for
kEventMenuEnableItemsautomatically sends this event to your menu commands. As this can cause a performance hit if you have many menu items, you can choose to bypass these updates by installing a no-op handler forkEventMenuEnableItemsthat simply returnsnoErr.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
You pass this constant to the CreateEvent function to indicate the type of command event you want to create. Future releases of the Carbon Event Manager will provide additional command event types.
Table 3 shows the parameters associated with command events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Standard Command ID Constants
Define command IDs for common menu commands and controls.
enum {
kHICommandOK = 'ok ',
kHICommandCancel = 'not!',
kHICommandQuit = 'quit',
kHICommandUndo = 'undo',
kHICommandRedo = 'redo',
kHICommandCut = 'cut ',
kHICommandCopy = 'copy',
kHICommandPaste = 'past',
kHICommandClear = 'clea',
kHICommandSelectAll = 'sall',
kHICommandHide = 'hide',
kHICommandHideOthers = 'hido',
kHICommandShowAll = 'shal',
kHICommandPreferences = 'pref',
kHICommandZoomWindow = 'zoom',
kHICommandMinimizeWindow = 'mini',
kHICommandMinimizeAll = 'mina',
kHICommandMaximizeWindow = 'maxi',
kHICommandMaximizeAll = 'maxa',
kHICommandArrangeInFront = 'frnt',
kHICommandBringAllToFront = 'bfrt',
kHICommandWindowListSeparator = 'wldv',
kHICommandWindowListTerminator = 'wlst',
kHICommandSelectWindow = 'swin',
kHICommandRotateWindowsForward = 'rotw',
kHICommandRotateWindowsBackward = 'rotb',
kHICommandRotateFloatingWindowsForward = 'rtfw',
kHICommandRotateFloatingWindowsBackward = 'rtfb',
kHICommandAbout = 'abou',
kHICommandNew = 'new ',
kHICommandOpen = 'open',
kHICommandClose = 'clos',
kHICommandSave = 'save',
kHICommandSaveAs = 'svas',
kHICommandRevert = 'rvrt',
kHICommandPrint = 'prnt',
kHICommandPageSetup = 'page',
kHICommandAppHelp = 'ahlp',
kHICommandShowCharacterPalette = 'chrp',
kHICommandShowSpellingPanel = 'shsp',
kHICommandCheckSpelling = 'cksp',
kHICommandChangeSpelling = 'chsp',
kHICommandCheckSpellingAsYouType = 'chsp',
kHICommandIgnoreSpelling = 'igsp',
kHICommandLearnWord = 'lrwd'
};
Constants
kHICommandOKThe OK button in a dialog or alert.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandCancelThe Cancel button in a dialog or alert.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandQuitThe application should quit.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandUndoThe last editing operation should be undone.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandRedoThe last editing operation should be redone.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandCutThe selected items should be cut.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandCopyThe selected items should be copied.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandPasteThe contents of the clipboard should be pasted.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandClearThe selected items should be deleted.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandSelectAllAll items in the active window should be selected.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandHideThe application should be hidden. The Menu Manager responds to this command automatically; your application does not need to handle it.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandHideOthersOther applications should be hidden. The Menu Manager responds to this command automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandShowAllAll applications should become visible. The Menu Manager responds to this command automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandPreferencesThe Preferences menu item has been selected.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandZoomThe active window should be zoomed in or out. The default application handler responds to this event automatically. Your application does not need to handle this event, but you may want to install a Carbon event handler for
kEventWindowGetIdealSizeto return the ideal size for your document windows.kHICommandMinimizeWindowThe active window should be minimized. The default application handler will respond to this event automatically; your application does not need to handle it.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandMinimizeAllAll collapsable windows should be minimized. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandMaximizeWindowThe active window should be maximized. Sent only on Mac OS 9. The default application handler will respond to this event automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandMaximizeAllAll collapsible windows should be maximized. This event is not sent or handled on Mac OS X.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandArrangeInFrontAll document-class windows should be arranged in a stack. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandBringAllToFrontAll windows of this application should be brought in front of windows from other applications. Sent only on Mac OS X. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandWindowListSeparatorA placeholder to mark the separator item dividing the Zoom/Minimize/Maximize/Arrange menu items in the standard Window menu from the menu items listing the visible windows. If you need to add your own menu items to the standard Window menu before the window list section, you can use
GetIndMenuItemWithCommandID(described in the Menu Manager Reference in the User Experience section of the Carbon documentation) to look for the menu item with this command ID and insert your menu items before the item with this ID.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandWindowListTerminatorUsed as a placeholder to mark the end of the window list section of the standard Window menu. If you need to add your own menu items to the standard Window menu after the window list section, you can use
GetIndMenuItemWithCommandID(described in the Menu Manager Reference in the User Experience section of the Carbon documentation) to look for the menu item with this command ID and insert your items after the item with this ID.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandSelectWindowA window in the standard Window menu has been selected and should be activated. In Mac OS X v10.3, this command is also sent by the toolbox whenever it needs to activate a window in your application. For example, it is used when a window is selected from the application’s Dock menu, and when a window that uses the standard window event handler is clicked. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandRotateWindowsForwardThe Rotate Windows hot key (cmd-~ by default) has been pressed. Non-floating windows should be rotated so that the window after the active window is activated. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kHICommandRotateWindowsBackwardThe Rotate Windows hot key (cmd-~ by default) has been pressed. Non-floating windows should be rotated so that the window before the active window is activated. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kHICommandRotateFloatingWindowsForwardThe floating window focus hot key (ctl-F6 by default) has been pressed, and floating windows should be rotated so that the window after the focused window is activated. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kHICommandRotateFloatingWindowsBackwardThe floating window focus hot key (ctl-F6 by default) has been pressed, and floating windows should be rotated so that the window before the focused window is activated. The default application handler responds to this event automatically; your application does not need to handle it.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kHICommandAboutThe About menu item has been selected. In Mac OS X v10.3 and later,
RunApplicationEventLoopinstalls a handler for this command ID on the application target that handles this event automatically by callingHIAboutBox. Your application can install its own handler if you want to display a customized about box.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandNewA new document or item should be created.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandOpenThe user wants to open an existing document.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandCloseThe active window should be closed. This command is typically be generated by a Close menu item. In Mac OS X v10.3 and later, the default application handler responds to this command by sending a
kEventWindowCloseevent; on earlier systems, only the standard window event handler responded to this event.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandSaveThe active document should be saved.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandSaveAsThe user wants to save the active document under a new name.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandRevertThe contents of the active document should be reverted to the last saved version.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandPrintThe active window should be printed.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandPageSetupThe user wants to configure the current page margins, formatting, and print options.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandAppHelpThe application’s help book should be displayed. The Help Manager installs a handler for this command ID on the Help menu returned by
HMGetHelpMenuand responds to this event automatically. Your application does not need to handle it. In Mac OS X v10.4, the Help Manager installs a handler for this event on the application event target rather than on the Help menu.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kHICommandShowCharacterPaletteThe character palette needs to be shown. Events with this command ID are only generated in Mac OS X v10.3 and later. The toolbox will respond to this event automatically; your application does not need to handle it.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kHICommandShowSpellingPanelDisplay the spelling panel if it is not already visible. Events with this command ID are only generated in Mac OS X v10.4 and later. If spell checking has been enabled in the Multilingual Text Engine (MLTE) or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHICommandCheckSpellingSpell check the document now. Events with this command ID are only generated in Mac OS X v10.4 and later. If spell checking has been enabled in MLTE or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHICommandChangeSpellingChange the spelling. Events with this command ID are only generated in Mac OS X v10.4 and later. If spell checking has been enabled in MLTE or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHICommandCheckSpellingAsYouTypeBegin interactive spell checking. Events with this command ID are only generated in Mac OS X v10.4 and later. If spell checking has been enabled in MLTE or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHICommandIgnoreSpellingIgnore this word while spell checking this text view. Events with this command ID are only generated in Mac OS X v10.4 and later. If spell checking has been enabled in MLTE or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHICommandLearnWordLearn this spelling for all documents. Events with this command ID are generated only in Mac OS X v10.4 and later. If spell checking has been enabled in MLTE or an HITextView, this command is handled automatically.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Discussion
You should use these values for standard menu and control commands rather than defining your own.
Command Event Source Constants
Define constants for the user interface element that produced an HICommand event.
enum {
kHICommandFromMenu = (1L << 0),
kHICommandFromControl = (1L << 1),
kHICommandFromWindow = (1L << 2)
};
Constants
kHICommandFromMenuThis bit is set for commands generated from menu items in all versions of CarbonLib and Mac OS X.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kHICommandFromControlThe command event originated from a control. This bit was introduced in Mac OS X v10.2 and CarbonLib 1.6; it is never set in earlier versions of Mac OS X or CarbonLib.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kHICommandFromWindowThe command event originated from a window. This bit was introduced in Mac OS X v10.2 and CarbonLib 1.6; it is never set in earlier versions of Mac OS X or CarbonLib.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Control Events
Control Event Constants
Define constants related to events from kEventClassControl.
enum {
kEventControlInitialize = 1000,
kEventControlDispose = 1001,
kEventControlGetOptimalBounds = 1003,
kEventControlDefInitialize = kEventControlInitialize,
kEventControlDefDispose = kEventControlDispose,
kEventControlHit = 1,
kEventControlSimulateHit = 2,
kEventControlHitTest = 3,
kEventControlDraw = 4,
kEventControlApplyBackground = 5,
kEventControlApplyTextColor = 6,
kEventControlSetFocusPart = 7,
kEventControlGetFocusPart = 8,
kEventControlActivate = 9,
kEventControlDeactivate = 10,
kEventControlSetCursor = 11,
kEventControlContextualMenuClick = 12,
kEventControlClick = 13,
kEventControlGetNextFocusCandidate = 14,
kEventControlGetAutoToggleValue = 15,
kEventControlInterceptSubviewClick = 16,
kEventControlGetClickActivation = 17,
kEventControlDragEnter = 18,
kEventControlDragWithin = 19,
kEventControlDragLeave = 20,
kEventControlDragReceive = 21,
kEventControlTrack = 51,
kEventControlGetScrollToHereStartPoint = 52,
kEventControlGetIndicatorDragConstraint = 53,
kEventControlIndicatorMoved = 54,
kEventControlGhostingFinished = 55,
kEventControlGetActionProcPart = 56,
kEventControlGetPartRegion = 101,
kEventControlGetPartBounds = 102,
kEventControlSetData = 103,
kEventControlGetData = 104,
kEventControlGetSizeConstraints = 105,
kEventControlValueFieldChanged = 151,
kEventControlAddedSubControl = 152,
kEventControlRemovingSubControl = 153,
kEventControlBoundsChanged = 154,
kEventControlTitleChanged = 158,
kEventControlOwningWindowChanged = 159,
kEventControlHiliteChanged = 160,
kEventControlEnabledStateChanged = 161,
kEventControlArbitraryMessage = 201
};
Constants
kEventControlInitializeSent when a control is created. Allows the control to initialize private data.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlDisposeSent when a control is disposed. Allows the control to dispose of private data.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetOptimalBoundsAllows the control to report its best size and its text baseline based on its current settings. You should set the
kEventParamControlOptimalBoundsparameter to an appropriate rectangle. You should also set thekEventParamControlOptimalBaselineOffsetparameter to be the offset from the top of your optimal bounds of a text baseline, if any. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlDefInitializeSame as
kEventControlInitialize. You can use this event when creating custom control definitions.Available in OS X v10.0 through OS X v10.2.
Declared in
CarbonEvents.h.kEventControlDefDisposeSame as
kEventControlDispose. You can use this event when creating custom control definitions.Available in OS X v10.0 through OS X v10.2.
Declared in
CarbonEvents.h.kEventControlHitSent by the Control Manager functions
TrackControlandHandleControlClickafter handling a click in a control. If you do not handle this event, and the control has a command ID associated with it, then the Control Manager sends akEventCommandProcessevent to the control.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlSimulateHitSent when your control should simulate a click in response to some other action, such as a return key for a default button. The default behavior is to use the Control Manager function
HiliteControlto highlight and unhighlight the part specified in thekEventParamControlPartparameter (simulating the hit) and then call the control’s action callback function. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlHitTestSent when someone wants to find out what part of your control is at a given point in local coordinates. You should set the
kEventParamControlPartparameter to the appropriate part. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlDrawSent when your control should draw itself. The event can optionally contain parameters indicating which port to draw into and which part to constrain drawing to. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlApplyBackgroundSent when your control should apply its background color/pattern to the port specified so the subcontrol can properly erase. The port is optional; if it does not exist you should apply the background to the current port. Note that if you don’t handle this event, the event is propagated to the control’s parent. (Mac OS X only)
Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventControlApplyTextColorSent when your control should apply a color/pattern to the specified port and context so a subcontrol can draw text which looks appropriate for your control’s background. The port is optional; if it does not exist, you should apply the text color to the current port. The context is also optional. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlSetFocusPartSent when your control is gaining, losing, or changing the focus. Set the focus to the part indicated by the
kEventParamControlPartparameter. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetFocusPartSent when your the Control Manager wants to know what part of your control is currently focused. Set the
kEventParamControlPartparameter to your currently focused part. If you don’t handle this event, the Control Manager sets the part parameter to the last part that was focused (or no part if the control lost focus). (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlActivateSent when your control becomes active as a result of a call to
ActivateControl. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlDeactivateSent when your control becomes inactive as a result of a call to
DeactivateControl. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlSetCursorSent when your control is asked to change the cursor as a result of a call to the Control Manager function
HandleControlSetCursor. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlContextualMenuClickSent when your control is asked to display a contextual menu as a result of a call to the Control Manager function
HandleControlContextualMenuClick. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlClickA mouse down occurred in a control. The standard window handler sets the keyboard focus to the control if it takes focus on clicks, and calls the Control Manager function
HandleControlClick.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetNextFocusCandidateSent to allow a control to customize the focus order of its subcontrols. The current subcontrol with focus is stored in the
kEventParamStartControlparameter. The desired focus direction is indicated by thekControlFocusNextPartorkControlFocusPrevPartconstants, passed to you in thekEventParamControlPartparameter. The handler should return the next subcontrol in thekEventParamNextControlparameter. If thekEventParamStartControlparameter isNULL, return the first subcontrol in the specified focus direction. If no next subcontrol exists in the desired focus direction, returnNULLor omit thekEventParamNextControlparameter.The default behavior is to return the “most appropriate” peer control, which currently means the previous control in the ordering scheme.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlGetAutoToggleValueSent when the system wants to auto-toggle a control. You can specify the value to use based on the current value of your control.
If the control has the
kControlAutoTogglesfeature bit set, then the default behavior is as follows:If the control does not behave like a radio button (the
kControlHasRadioBehaviorfeature bit is not set), and its value is 1, then thekEventParamControlValueparameter is set to 0.If the control’s value is anything other than 1, the
kEventParamControlValueparameter is set to 0.
Otherwise, there is no default behavior.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlInterceptSubviewClickSent when the
HIViewGetViewForMouseClickfunction is called (typically by the Control Manager before it descends into subviews). A view can use this event to intercept mouse clicks that would normally be destined for one of its subviews. For example, the Toolbar control uses this event to intercept command-clicks so that it can handle dragging of its children. If the command key is down, the user wants to drag, so the handler returnsnoErrto indicate that this view (the Toolbar) should receive the click, not the child that was actually under the mouse.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlGetClickActivationSent when a mouse click occurs in a background (inactive) control. This event is essentially the control version of
kEventWindowGetClickActivation. The only differences are that the mouse location is view-relative and no window part parameter is passed to you.This event is sent only when the standard window handler is installed. The default behavior is to activate the view and absorb the mouse click (that is, the click is not passed on to the view).
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlDragEnterSent when a drag item enters a view’s bounds. If you want to respond to the drag, your drag entered handler must return
noErrIf you returneventNotHandledErrthen you will not receive further drag events, nor will you be able to receive the drag item.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlDragWithinSent when a drag item has moved while in the view’s bounds (but not within any of its subviews). If the drag subsequently enters a subview, all additional drag events are directed to that subview.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlDragLeaveSent when a drag item leaves your view. You can use this event to unhighlight your view, and so on. (Available in Mac OS X v10.2 and later.)
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlDragReceiveSent when a drag item is dropped within your view.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlTrackSent to allow your control to completely replace the normal tracking that is part of a call to the Control Manager functions
TrackControlorHandleControlClick. Set thekEventParamControlPartto the part hit during tracking.This event is sent only to controls that return a non-zero control part code from
kEventControlHitTest. If you are implementing a custom HIView and you need to receive this event, you must also handlekEventControlHitTest. The hit-test handler must place a valid control part code into thekEventParamControlPartparameter and returnnoErr.The default behavior is to implement indicator tracking (if the mouse is down in an indicator part, such as for a scroll bar) or one-part tracking (if the mouse is down in a button or similar part). If the tracking is successful, the Control Manager passes back the part that was hit.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetScrollToHereStartPointSent so your control can support “Scroll To Here” behavior during tracking. Set the
kEventParamMouseLocationparameter to the mouse location in local coordinates which represents where a click would have needed to be to cause your indicator to be dragged to the incoming mouse location. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetIndicatorDragConstraintSent so your control can constrain the movement of its indicator during tracking. Set the
kEventParamControlIndicatorDragConstraintparameter to the appropriate constraint. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlIndicatorMovedSent during live-tracking of the indicator so your control can update its value based on the new indicator position. During non-live tracking, this event lets you redraw the indicator ghost at the appropriate place. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGhostingFinishedSent at the end of non-live indicator tracking so your control can update its value based on the final ghost location. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetActionProcPartSent during tracking so your control can alter the part that is passed to its action callback based on modifier keys, etc. Set the
kEventParamControlPartto the part you want to have sent. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetPartRegionSent when a client wants to get a particular region of your control. See the
GetControlRegionfunction in the Control Manager. ThekEventParamControlRegioncontains a region for you to modify.If the requested part is
kControlStructureMetaPart, the default behavior is to pass back a region equal to the control’s bounds. Otherwise, there is no default behavior.(Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetPartBoundsSent when a client wants to get a particular rectangle of your control when it may be more efficient than asking for a region. Set the
kEventParamControlPartBoundsparameter to the appropriate rectangle. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlSetDataSent when a client wants to change an arbitrary setting of your control. See the
SetControlDatafunction in the Control Manager. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetDataSent when a client wants to get an arbitrary setting of your control. See the Control Manager function
GetControlData. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlGetSizeConstraintsSent when the
HIViewGetSizeContraintsfunction is called. You use this to let your custom view indicate its maximum and minimum size. A parent view can use this information to help it lay out subviews.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlValueFieldChangedSent when your control’s value, minimum, maximum, or view size has changed. Useful so other entities can watch for your control’s value to change. If the window does not have compositing enabled, the default behavior is to redraw the control (but not its subcontrols). (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlAddedSubControlSent when a control is embedded within your control.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlRemovingSubControlSent when one of your child controls will be removed from your control.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlBoundsChangedSent when your control’s bounding rectangle has changed. Note that the
kEventParamOriginalBoundsandkEventParamPreviousBoundsparameters for this event contain the same value.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlTitleChangedSent when your control’s title changes.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlOwningWindowChangedSent when one your control’s owning window has changed. Useful to update any dependencies that your control has on its owning window. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventControlHiliteChangedSent when a control’s highlight state changes.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlEnabledStateChangedSent when a control’s enabled state changes (that is, when a control is enabled or disabled).
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventControlArbitraryMessageSent when someone tries to send an old-style CDEF message to your control. In most cases, you should implement Carbon event replacements for CDEF messages instead. If you do handle this event, but do not explicitly handle a particular CDEF message, you should propagate this event up the handler chain (either explicitly by calling
CallNextEventHandleror implicitly by returningeventNotHandledErr), as some default behavior may be implemented for compatibility purposes. (Mac OS X only)Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.
Discussion
You can specify any of these events when installing an event handler. You can also pass these constants to the CreateControlEvent function to specify the type of control event you want to create.
Note that many control events are not sent as a request for you to take action; rather they provide a way for the application to override default behavior. Because this is the case, most control events do not have a standard handler associated with them. Their default behavior occurs whether or not you have the standard window handler installed.
Table 4 shows the parameters available for control events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Control Bounds Constants
Define control bounds change-event attributes.
enum {
kControlBoundsChangeSizeChanged = (1 << 2),
kControlBoundsChangePositionChanged = (1 << 3)
};
Constants
kControlBoundsChangeSizeChangedThe dimensions of the control (width and height) changed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kControlBoundsChangePositionChangedThe position of the control changed (that is, the top-left corner moved).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
When the system sends out a kEventControlBoundsChanged event, it also sends along a parameter containing attributes of the event. These attributes can be used to determine what aspect of the control changed (position, size, or both).
Control Event Parameters
Define parameters related to control events.
enum {
kEventParamControlPart = 'cprt',
kEventParamInitCollection = 'icol',
kEventParamControlMessage = 'cmsg',
kEventParamControlParam = 'cprm',
kEventParamControlResult = 'crsl',
kEventParamControlRegion = 'crgn',
kEventParamControlAction = 'caup',
kEventParamControlIndicatorDragConstraint = 'cidc',
kEventParamControlIndicatorRegion = 'cirn',
kEventParamControlIsGhosting = 'cgst',
kEventParamControlIndicatorOffset = 'ciof',
kEventParamControlClickActivationResult = 'ccar',
kEventParamControlSubControl = 'csub',
kEventParamControlOptimalBounds = 'cobn',
kEventParamControlOptimalBaselineOffset = 'cobo',
kEventParamControlDataTag = 'cdtg',
kEventParamControlDataBuffer = 'cdbf',
kEventParamControlDataBufferSize = 'cdbs',
kEventParamControlDrawDepth = 'cddp',
kEventParamControlDrawInColor = 'cdic',
kEventParamControlFeatures = 'cftr',
kEventParamControlPartBounds = 'cpbd',
kEventParamControlOriginalOwningWindow = 'coow',
kEventParamControlCurrentOwningWindow = 'ccow',
kEventParamControlFocusEverything = 'cfev',
kEventParamNextControl = 'cnxc',
kEventParamStartControl = 'cstc',
kEventParamControlSubview = 'csvw',
kEventParamControlPreviousPart = 'copc',
kEventParamControlCurrentPart = 'cnpc',
kEventParamControlInvalRgn = 'civr',
kEventParamControlValue = 'cval',
kEventParamControlHit = 'chit',
kEventParamControlPartAutoRepeats = 'caur',
kEventParamControlFrameMetrics = 'cfmt',
kEventParamControlWouldAcceptDrop = 'cldg',
kEventParamControlPrefersShape = 'cpsh',
typeControlActionUPP = 'caup',
typeIndicatorDragConstraint = 'cidc',
typeControlPartCode = 'cprt',
typeControlFrameMetrics = 'cins'
};
Constants
kEventParamControlParttypeControlPartCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamInitCollectiontypeCollection
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlMessagetypeShortInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlParamtypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlResulttypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlRegiontypeQDRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlActiontypeControlActionUPP
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlIndicatorDragConstrainttypeIndicatorDragConstraint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlIndicatorRegiontypeQDRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlIsGhostingtypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlIndicatorOffsettypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlClickActivationResulttypeClickActivationResult
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlSubControltypeControlRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlOptimalBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlOptimalBaselineOffsettypeShortInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlDataTagtypeEnumeration
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlDataBuffertypePtr
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlDataBufferSizetypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlDrawDepthtypeShortInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlDrawInColortypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlFeaturestypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlPartBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlOriginalOwningWindowtypeWindowRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlCurrentOwningWindowtypeWindowRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamControlFocusEverythingtypeBoolean
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamNextControltypeControlRef
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamStartControltypeControlRef
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlSubviewtypeControlRef
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlPreviousParttypeControlPartCode
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlCurrentParttypeControlPartCode
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlInvalRgntypeQDRgnHandle
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlValuetypeLongInteger
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamControlHittypeBoolean
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamControlPartAutoRepeatstypeBoolean
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamControlFrameMetricstypeControlFrameMetrics
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamControlWouldAcceptDroptypeBoolean
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamControlPrefersShapetypeBoolean
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.typeControlActionUPPControlActionUPP
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeIndicatorDragConstraintIndicatorDragConstraint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeControlPartCodeControlPartCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeControlFrameMetricsHIViewFrameMetrics
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Ink Events
Ink Event Constants
Define constants related to events from kEventClassInk.
enum {
kEventInkPoint = 10,
kEventInkGesture = 11,
kEventInkText = 12
};
Constants
kEventInkPointA mouse event will be handled as an ink point and used for recognition. The Ink Manager has determined that the mouse event in
kEventParamEventRefshould be used for recognition. If the application handles the event and returnsnoErr, the Ink Manager does nothing further with the mouse event. If the application returns any other value (includingeventNotHandledErr), the Ink Manager processes the point normally.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventInkGestureThe Ink Manager recognizes the current ink phrase as one of the known system gestures. Applications can install a handler for these events to provide targeted gestures and support for context-dependent (tentative) gestures. Applications should return
noErrif they handled the gesture. If the gesture was context dependent and does not apply to the current situation, applications should returneventNotHandledErr.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventInkTextThe Ink Manager recognizes a word. The
kEventParamInkTextRefparameter contains the ink text reference with all the information about the word. For more information, seeInk.h.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Discussion
Table 6 shows the parameters associated with ink events
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ink Event Parameters
Define constants for parameters to ink events.
enum {
kEventParamInkTextRef = 'iwrd',
kEventParamInkKeyboardShortcut = 'ikbd',
kEventParamInkGestureKind = 'gknd',
kEventParamInkGestureBounds = 'gbnd',
kEventParamInkGestureHotspot = 'ghot'
};
Constants
kEventParamInkTextRefThe ink text reference containing the data for the word the Ink Manager recognized. (
typePtr)Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamInkKeyboardShortcutA Boolean whose value indicates whether the word the Ink Manager recognized is a keyboard shortcut. That is, the Command or Control key was pressed and the top-choice alternate text is a single character. (
typeBoolean)Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamInkGestureKindKind of gesture. (
typeUInt32)Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamInkGestureBoundsBounds of the gesture in global coordinates. (
typeHIRect)Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamInkGestureHotspotHotspot, in global coordinates, for the gesture. (
typeHIPoint)Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Keyboard Events
Keyboard Event Constants
Define constants related to events from kEventClassKeyboard.
enum {
kEventRawKeyDown = 1,
kEventRawKeyRepeat = 2,
kEventRawKeyUp = 3,
kEventRawKeyModifiersChanged = 4,
kEventHotKeyPressed = 5,
kEventHotKeyReleased = 6
};
Constants
kEventRawKeyDownA key was pressed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventRawKeyRepeatSent periodically as a key is held down by the user.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventRawKeyUpA key was released.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventRawKeyModifiersChangedThe keyboard modifiers have changed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventHotKeyPressedA registered hot key was pressed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventHotKeyReleasedA registered hot key was released.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
These events are the lowest-level keyboard events.
Table 6 shows the parameters associated with keyboard events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Key Modifier Event Masks
Define values used to determine whether additional modifier keys are down for a keyboard or mouse event.
enum {
kEventKeyModifierNumLockMask = 1L << kEventKeyModifierNumLockBit,
kEventKeyModifierFnMask = 1L << kEventKeyModifierFnBit
};
Constants
kEventKeyModifierNumLockMaskA bit mask containing
kEventKeyModifierNumLockBit. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventKeyModifierFnMaskA bit mask containing
kEventKeyModifierFnBit. (Mac OS X only)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Key Modifier Event Bits
Define key modifier change event bits.
enum {
kEventKeyModifierNumLockBit = 16,
kEventKeyModifierFnBit = 17
};
Constants
kEventKeyModifierNumLockBitThis keyboard event was generated either on the numeric keypad or in the numeric section of an iBook or PowerBook keyboard with the Num Lock key pressed. This state bit does not provide an indication of the Num Lock key on non-portable keyboards. This bit is set on Mac OS X only.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventKeyModifierFnBitThe Fn key was pressed when this keyboard event was generated. This bit is set on Mac OS X only.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
Note that bits 8 through 15 (cmdKeyBit to rightControlKeyBit) are compatible with the Classic Event Manager modifiers.
Keyboard Event Parameters and Types
Define constants for parameters to raw keyboard events.
enum {
kEventParamKeyCode = 'kcod',
kEventParamKeyMacCharCodes = 'kchr',
kEventParamKeyModifiers = 'kmod',
kEventParamKeyUnicodes = 'kuni',
kEventParamKeyboardType = 'kbdt',
typeEventHotKeyID = 'hkid'
};
Constants
kEventParamKeyCodetypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamKeyMacCharCodestypeChar
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamKeyModifierstypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamKeyUnicodestypeUnicodeText
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeEventHotKeyIDEventHotKeyID
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Symbolic Hot Key Definitions
Define CFDictionaryRef keys returned by CopySymbolicHotKeys.
#define kHISymbolicHotKeyCode CFSTR("kHISymbolicHotKeyCode")
#define kHISymbolicHotKeyModifiers CFSTR("kHISymbolicHotKeyModifiers")
#define kHISymbolicHotKeyEnabled CFSTR("kHISymbolicHotKeyEnabled")
Constants
kHISymbolicHotKeyCodeThe virtual key code of the hot key, represented as a CFNumber.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kHISymbolicHotKeyModifiersThe hot key’s keyboard modifiers, represented as a CFNumber.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kHISymbolicHotKeyEnabledThe enable state of the hot key, represented as a CFBoolean.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Hot Key Constants
Define hot key states used by PushSymbolicHotKeyMode.
enum {
kHIHotKeyModeAllEnabled = 0,
kHIHotKeyModeAllDisabled = (1 << 0),
kHIHotKeyModeAllDisabledExceptUniversalAccess = (1 << 1)
};
Constants
kHIHotKeyModeAllEnabledAll hot keys are enabled.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIHotKeyModeAllDisabledAll hot keys are disabled.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIHotKeyModeAllDisabledExceptUniversalAccessAll hot keys are disabled except for the Universal Access hot keys (that is, zooming, white-on-black, and enhanced contrast).
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Menu Events
Menu Event Constants
Define constants related to events from kEventClassMenu.
enum {
kEventMenuBeginTracking = 1,
kEventMenuEndTracking = 2,
kEventMenuChangeTrackingMode = 3,
kEventMenuOpening = 4,
kEventMenuClosed = 5,
kEventMenuTargetItem = 6,
kEventMenuMatchKey = 7,
kEventMenuEnableItems = 8,
kEventMenuPopulate = 9,
kEventMenuMeasureItemWidth = 100,
kEventMenuMeasureItemHeight = 101,
kEventMenuDrawItem = 102,
kEventMenuDrawItemContent = 103,
kEventMenuDispose = 1001,
kEventMenuCalculateSize = 1004,
kEventMenuCreateFrameView = 1005,
kEventMenuGetFrameBounds = 1006,
kEventMenuBecomeScrollable = 1007,
kEventMenuCeaseToBeScrollable = 1008,
kEventMenuBarShown = 2000,
kEventMenuBarHidden = 2001
};
Constants
kEventMenuBeginTrackingThe user has begun tracking the menubar or a pop-up menu. The direct object parameter is a valid menu reference if tracking a pop-up menu, or
NULLif tracking the menubar. ThekEventParamCurrentMenuTrackingModeparameter indicates whether the user is tracking the menus using the mouse or the keyboard. The handler may returnuserCanceledErrto stop menu tracking.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuEndTrackingThe user has finished tracking the menubar or a pop-up menu. In Mac OS X v10.3 and later, when a menu tracking session ends, the Menu Manager sends
kEventMenuEndTrackingto every menu that was opened during the session, in addition to the root menu. This is done to allow menus with dynamic content to remove that content at the end of menu tracking; for example, a menu containing many IconRefs might want to load the IconRefs dynamically in response to thekEventMenuMenuPopulateevent and remove them in response to thekEventMenuEndTrackingevent to avoid the memory overhead of keeping the IconRef data in memory while the menu is not being displayed.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuChangeTrackingModeThe user has switched from selecting a menu with the mouse to selecting with the keyboard, or from selecting with the keyboard to selecting with the mouse.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuOpeningA menu is opening. This event is sent each time that the menu is opened (that is, more than once during a given tracking session if the user opens the menu multiple times). It is sent before the menu is actually drawn, so you can update the menu contents (including making changes that will alter the menu size) and the new contents will be drawn correctly. The
kEventParamMenuFirstOpenparameter indicates whether this is the first time this menu has been opened during this menu tracking session. The handler may returnuserCanceledErrto prevent this menu from opening. Note that for most applications, you should handle thekEventMenuPopulateevent instead.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuClosedA menu has been closed. Sent after the menu is hidden.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuTargetItemThe mouse is moving over a particular menu item. This event is sent for both enabled and disabled items.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuMatchKeyA menu is about to be examined for items that match a command key event. A handler for this event may perform its own command key matching and override the Menu Manager’s default matching algorithms. Returning
noErrfrom your handler indicates that you have found a match. The handler for this event should not examine submenus of this menu for a match; a separate event will be sent for each submenu.When called from
IsMenuKeyEvent, thekEventParamEventRefparameter contains the event reference that was passed toIsMenuKeyEvent, for your handler to examine; when called fromMenuKeyorMenuEvent, theEventRefparameter contains an event created from the information passed toMenuKeyorMenuEvent. Note that in theMenuKeycase, no virtual key code (kEventParamKeyCode) or key modifiers (kEventParamKeyModifiers) will be available.The
kEventParamMenuEventOptionsparameter contains a copy of the options that were passed toIsMenuKeyEvent, or0if called fromMenuKeyorMenuEvent. The only option that your handler will need to obey iskMenuEventIncludeDisabledItems.If your handler finds a match, it should set the
kEventParamMenuItemIndexparameter to contain the item index of the matching item, and returnnoErr. If it does not find a match, it should returnmenuItemNotFoundErr. Any other return value will cause the Menu Manager to use its default command key matching algorithm for this menu.This event is sent after
kEventMenuEnableItems.In CarbonLib and Mac OS X through version 10.3, the Menu Manager sends a
kEventMenuEnableItemsevent to the menu before sendingkEventMenuMatchKey. In Mac OS X 10.4 and later, the Menu Manager no longer sendskEventMenuEnableItems(or the resultingkEventCommandUpdateStatusevents) to the menu; a handler forkEventMenuMatchKeyis expected to determine on its own whether a matching menu item is enabled.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuEnableItemsA request that the items in the menu be properly enabled or disabled according to the current state of the application. This event is sent from inside
MenuKey,MenuEvent, andIsMenuKeyEventbefore those functions examine the menu for an item that matches a keyboard event. It is also sent during menu tracking before a menu is first made visible; it is sent right afterkEventMenuOpening, once per menu per menu tracking session.If you install an event handler for
kEventProcessCommand, you should also install a handler forkEventMenuEnableItems. This is necessary because the Carbon event system will attempt to match command keys against the available menus before returning the keyboard event to your application viaWaitNextEvent. If you have menu command event handlers installed for your menu items, your handlers will be called without you ever receiving the keyboard event or callingMenuKey/MenuEvent/IsMenuKeyEventyourself. Therefore, you have no opportunity to enable your menu items properly other than from akEventMenuEnableItemshandler.It is not necessary to handle this event if you do not install
kEventProcessCommandhandlers for your menu items; in that case, the command key event will be returned fromWaitNextEventorReceiveNextEventas normal, and you can set up your menus before callingMenuKey/MenuEvent/IsMenuKeyEvent.The
kEventParamEnableMenuForKeyEventparameter indicates whether this menu should be enabled for key event matching (true) or because the menu itself is about to become visible (false). If true, only the item enable state, command key, command key modifiers, and (optionally) the command key glyph need to be correct. If false, the entire menu item contents must be correct. This may be useful if you have custom menu content that is expensive to prepare.Note that the standard application handler for
kEventMenuEnableItemsautomatically sendskEventCommandUpdateStatusto your menu commands. As this can cause a performance hit if you have many menu items, you can choose to bypass these updates by installing a no-op handler forkEventMenuEnableItemsthat simply returnsnoErr.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuPopulateSent when an application should dynamically create a menu. You should use this event instead of
kEventMenuOpeningas the Menu Manager sends it before it searches a menu for a matching command key sequence; therefore you can use this event to dynamically add menu items that have command-key equivalents, making them selectable even if the menu itself is never displayed. ThekEventMenuPopulateevent is sent just once during a menu tracking session, even if the menu is opened and closed multiple times; thekEventWindowOpeningevent is sent each time the menu opens.To determine whether this event was triggered by a command-key sequence, you should examine the
kEventParamMenuContextparameter for thekMenuContextKeyMatchingflag. If the event corresponds to the actual display of a menu, thekEventContextMenuBarTrackingorkEventContextPopUpTrackingflags are set.Note that in Mac OS X v10.2 and later, the Menu Manager sends this event before it searches a menu for a matching command ID. To determine if this event was triggered by a command ID, check for the
kMenuContextCommandIDSearchflag in thekEventParamMenuContextparameter. If that flag is set, the command ID that triggered this event is contained in thekEventParamMenuCommandparameter.)Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventMenuMeasureItemWidthSent by the standard window definition if a menu item has the
kMenuItemAttrCustomDrawattribute set. You should install your handler directly on the menu. Your handler should return a customized width for the menu item in thekEventParamMenuItemWidthparameter.The default behavior (if you are using the standard menu definition) is to return the standard width for the item.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventMenuMeasureItemHeightSent by the standard window definition if a menu item has the
kMenuItemAttrCustomDrawattribute set. You should install your handler directly on the menu. Your handler should return a customized height for the menu item in thekEventParamMenuItemHeightparameter.The default behavior (if you are using the standard menu definition) is to return the standard height for the item.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventMenuDrawItemSent by the standard window definition if a menu item has the
kMenuItemAttrCustomDrawattribute set. You should install your handler directly on the menu. Use your handler to override the drawing of the menu item and background.The default behavior (if you are using the standard menu definition) is to call the Appearance Manager function
DrawThemeMenuItemto draw the menu item’s background and content.If you have the standard event handler installed, the event also contains additional parameters indicating the bounds of the various portions of the menu item content, as well as the baseline of the menu item text. Using these parameters, you can call
CallNextEventHandlerto let the system handlers draw the standard menu content and then your handler can draw custom content on top.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventMenuDrawItemContentSent by the standard window definition if a menu item has the
kMenuItemAttrCustomDrawattribute set. You should install your handler directly on the menu. You use your handler to override the drawing of one or more parts of the menu item’s content (that is the mark character, icon, text, and command key information).When you receive this event, the background and highlighting (if applicable) has already been drawn using the standard system appearance.
The default behavior (if you are using the standard menu definition) is to draw the standard menu item content.
If you have the standard event handler installed, the event also contains additional parameters indicating the bounds of the various portions of the menu item content, as well as the baseline of the menu item text. Using these parameters, you can call
CallNextEventHandlerto let the system handlers draw the standard menu content and then your handler can draw custom content on top.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventMenuDisposeSent when a menu is being disposed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMenuCalculateSizeSent by
CalcMenuSizeto request that the menu calculate its size. The Menu Manager provides a default handler for all menus that calls the menu’s MDEF or menu content view to determine the menu size. Applications typically do not need to handle this event. A custom menu definition or menu content view should usekMenuSizeMsgorkEventControlGetOptimalBoundsto calculate its size. Note that if the menu uses an MDEF, the MDEF sets the menu’s width and height in response tokMenuSizeMsg. The default handler for this event saves the old width and height before calling the MDEF and restores them afterward.CalcMenuSizesets the final menu width and height based on the dimensions returned from this event; applications may override this event to customize the width or height of a menu by modifying thekEventParamDimensionsparameter. This event is sent only to the menu and is not propagated past the menu.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuCreateFrameViewRequests that a menu content view create the HIView that will be used to draw the menu window frame. The HIMenuView class provides a default handler for this event that creates an instance of the standard menu window frame view. This event is sent only to the menu content view and is not propagated past the view.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuGetFrameBoundsRequests that a menu content view calculate the bounding rect, in global coordinates, of the menu window frame that should contain the menu. This event is sent by the Menu Manager before displaying pull-down, popup, and hierarchical menus. It provides an opportunity for the menu content view to determine the position of the menu frame based on the position of the menu title, parent menu item, or popup menu location. The HIMenuView class provides a default handler for this event that calculates an appropriate location based on the bounds of the menu, the available screen space, and the frame metrics of the menu window content view. This event is sent only to the menu content view and is not propagated past the view.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuBecomeScrollableRequests that a menu content view prepare to be scrollable, which it does by installing the appropriate event handlers, timers, and the like. This event is sent by the Menu Manager when a menu becomes the most recently opened menu in the menu hierarchy. It is an indication that this menu content view is now a candidate for scrolling. The Menu Manager provides a default handler for this event that installs event handlers to provide automatic scrolling behavior for HIView-based menus. If a menu content view does not wish to use the Menu Manager’s default scrolling support, it can override this event and return
noErrto prevent the event from being propagated to the Menu Manager’s default handler. This event is sent only to the menu content view and is not propagated past the view.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuCeaseToBeScrollableRequests that a menu content view cease to be scrollable. This event is sent by the Menu Manager when a menu ceases to be the most recently opened menu. This occurs when the menu is closed, or when a submenu of the most recently opened menu is opened. It is an indication that this menu content view is no longer a candidate for scrolling. The Menu Manager provides a default handler for this event that removes event handlers installed in response to
kEventMenuBecomeScrollable. This event is sent only to the menu content view and is not propagated past the view.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuBarShownSent to all handlers registered for this event when the front process shows its menubar. This event is sent only to the application target.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventMenuBarHiddenSent to all handlers registered for this event when the front process hides its menubar. This event is sent only to the application target.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Discussion
Some menu events are sent or handled by the standard menu definition, which is a collection of handlers that define the default menu behavior. If you have specified a custom menu definition, you will not get the behavior provided by the standard definition.
Table 7 shows the parameters associated with menu events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
None |
|
|
None |
|
|
None |
|
|
None |
Menu Context Constants
Define constants that describe the usage or context of a menu event.
enum {
kMenuContextMenuBar = 1 << 0,
kMenuContextPullDown = 1 << 8,
kMenuContextPopUp = 1 << 9,
kMenuContextSubmenu = 1 << 10,
kMenuContextMenuBarTracking = 1 << 16,
kMenuContextPopUpTracking = 1 << 17,
kMenuContextKeyMatching = 1 << 18,
kMenuContextMenuEnabling = 1 << 19,
kMenuContextCommandIDSearch = 1 << 20
};
Constants
kMenuContextMenuBarThe menu associated with this event is in the menu bar or is a submenu of a menu in the menubar.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextPulldownThe menu associated with this event is a pulldown menu located in the menu bar.
kMenuContextPopUpThe menu associated with this event is a popup menu displayed by the Menu Manager function
PopUpMenuSelect.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextSubmenuThe menu associated with this event is a submenu of a pulldown or popup menu.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextMenuBarTrackingThis event is being sent while a menu is being tracked in the menu bar.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextPopUpTrackingThis event is being sent while a popup menu is being tracked.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextKeyMatchingThis event is being sent while trying to match a command-key equivalent to a menu item.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextMenuEnablingSent at idle time to update the enabled state of the menus.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMenuContextCommandIDSearchSent while trying to match a command ID using the Menu Manager function
CountMenuItemsWithCommandIDorGetIndMenuItemWithCommandID.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Discussion
The bits corresponding to these constants are set in the kEventParamMenuContext parameter of the menu event.
Menu Event Parameters
Define constants for parameters to menu events.
enum {
kEventParamCurrentMenuTrackingMode = 'cmtm',
kEventParamNewMenuTrackingMode = 'nmtm',
kEventParamMenuFirstOpen = '1sto',
kEventParamMenuItemIndex = 'item',
kEventParamMenuCommand = 'mcmd',
kEventParamEnableMenuForKeyEvent = 'fork',
kEventParamMenuEventOptions = 'meop',
kEventParamMenuContext = 'mctx',
kEventParamMenuItemBounds = 'mitb',
kEventParamMenuMarkBounds = 'mmkb',
kEventParamMenuIconBounds = 'micb',
kEventParamMenuTextBounds = 'mtxb',
kEventParamMenuTextBaseline = 'mtbl',
kEventParamMenuCommandKeyBounds = 'mcmb',
kEventParamMenuVirtualTop = 'mvrt',
kEventParamMenuVirtualBottom = 'mvrb',
kEventParamMenuDrawState = 'mdrs',
kEventParamMenuItemType = 'mitp',
kEventParamMenuItemWidth = 'mitw',
kEventParamMenuItemHeight = 'mith',
typeMenuItemIndex = 'midx',
typeMenuCommand = 'mcmd',
typeMenuTrackingMode = 'mtmd',
typeMenuEventOptions = 'meop',
typeThemeMenuState = 'tmns',
typeThemeMenuItemType = 'tmit'
};
Constants
kEventParamCurrentMenuTrackingModetypeMenuTrackingMode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamNewMenuTrackingModetypeMenuTrackingMode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMenuFirstOpentypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMenuItemIndextypeMenuItemIndex
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMenuCommandtypeMenuCommand
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamEnableMenuForKeyEventtypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMenuEventOptionstypeMenuEventOptions
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeMenuItemIndexMenuItemIndex
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeMenuCommandMenuCommand
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeMenuTrackingModeMenuTrackingMode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeMenuEventOptionsMenuEventOptions
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Services Menu Command Keys
Define CFDictionaryRef keys returned by CopyServicesMenuCommandKeys.
#define kHIServicesMenuProviderName CFSTR("kHIServicesMenuProviderName")
#define kHIServicesMenuItemName CFSTR("kHIServicesMenuItemName")
#define kHIServicesMenuCharCode CFSTR("kHIServicesMenuCharCode")
#define kHIServicesMenuKeyModifiers CFSTR("kHIServicesMenuKeyModifiers")
Constants
kHIServicesMenuProviderNameThe name of the service provider.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIServicesMenuItemNameThe name of the menu item.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIServicesMenuCharCodeThe character code of the menu item shortcut.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIServicesMenuKeyModifiersThe keyboard modifiers of the menu item shortcut in Menu Manager modifiers format.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Mouse Events
Mouse Events
Define constants related to events from kEventClassMouse.
enum {
kEventMouseDown = 1,
kEventMouseUp = 2,
kEventMouseMoved = 5,
kEventMouseDragged = 6,
kEventMouseEntered = 8,
kEventMouseExited = 9,
kEventMouseWheelMoved = 10
};
Constants
kEventMouseDownA mouse button was pressed. Note that if you install a handler for this event on a window, you must allow the event to propagate (either by calling
CallNextEventHandleror returningeventNotHandledErr) so that the window can be activated.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseUpA mouse button was released.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseMovedThe mouse moved.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseDraggedThe mouse moved, and a button was down.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseEnteredThe mouse entered a tracking region. Used with mouse tracking regions. See
CreateMouseTrackingRegionfor more information.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventMouseExitedThe mouse left a tracking region. Used with mouse tracking regions. See
CreateMouseTrackingRegionfor more information.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventMouseWheelMovedThe mouse wheel moved.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
Table 8 shows the parameters related to mouse events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
Mouse Button Constants
Define mouse button constants.
typedef UInt16 EventMouseButton;
enum {
kEventMouseButtonPrimary = 1,
kEventMouseButtonSecondary = 2,
kEventMouseButtonTertiary = 3
};
Constants
kEventMouseButtonPrimaryThe primary mouse button (default for one-button mice, typically the left button for multi-button mice).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseButtonSecondaryThe “right-click” mouse button.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseButtonTertiaryThe tertiary mouse button.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Mouse Wheel Constants
Define mouse scroll-wheel-axis constants.
typedef UInt16 EventMouseWheelAxis;
enum {
kEventMouseWheelAxisX = 0,
kEventMouseWheelAxisY = 1
};
Constants
kEventMouseWheelAxisXThe x-axis (left-right movement).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventMouseWheelAxisYThe y-axis (up-down movement).
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Mouse Tracking Region Options
Define constants used by the CreateMouseTrackingRegion function.
typedef UInt32 MouseTrackingOptions;
enum {
kMouseTrackingOptionsLocalClip = 0,
kMouseTrackingOptionsGlobalClip = 1,
kMouseTrackingOptionsStandard = kMouseTrackingOptionsLocalClip
};
Constants
kMouseTrackingOptionsLocalClipThe region passed to
CreateMouseTrackingRegionis defined in local coordinates, and that the region is clipped to the owning window’s content region.Available in OS X v10.2 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kMouseTrackingOptionsGlobalClipThe region passed to
CreateMouseTrackingRegionis defined in global coordinates and that the region is clipped to the owning window’s structure region.Available in OS X v10.2 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kMouseTrackingOptionsStandardSame as
kMouseTrackingOptionsLocalClip.Available in OS X v10.2 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.
Alternate Mouse Tracking Result Constants
Define constants for alternate mouse tracking results.
enum {
kMouseTrackingMousePressed = kMouseTrackingMouseDown,
kMouseTrackingMouseReleased = kMouseTrackingMouseUp
};
Constants
kMouseTrackingMousePressedThe user pressed any mouse button.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseReleasedThe user released the mouse button.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Mouse Event Parameters
Define constants for parameters to mouse events.
enum {
kEventParamMouseLocation = 'mloc',
kEventParamWindowMouseLocation = 'wmou',
kEventParamMouseButton = 'mbtn',
kEventParamClickCount = 'ccnt',
kEventParamMouseWheelAxis = 'mwax',
kEventParamMouseWheelDelta = 'mwdl',
kEventParamMouseDelta = 'mdta',
kEventParamMouseChord = 'chor',
kEventParamTabletEventType = 'tblt',
kEventParamMouseTrackingRef = 'mtrf',
typeMouseButton = 'mbtn',
typeMouseWheelAxis = 'mwax',
typeMouseTrackingRef = 'mtrf'
};
Constants
kEventParamMouseLocationtypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMouseButtontypeMouseButton
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamClickCounttypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMouseWheelAxistypeMouseWheelAxis
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMouseWheelDeltatypeSInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMouseDeltatypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamMouseChordtypeUInt32
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.typeMouseButtonEventMouseButton
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeMouseWheelAxisEventMouseWheelAxis
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Mouse Tracking Option Constant
Define options for the TrackMouseLocationWithOptions function.
enum {
kTrackMouseLocationOptionDontConsumeMouseUp = (1 << 0)
};
Constants
kTrackMouseLocationOptionDontConsumeMouseUpLeave mouse-up events in the event queue (the default is to pull them.)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
This constant can be passed to TrackMouseLocationWithOptions in the inOptions parameter.
Mouse Tracking Constants
Define constants for mouse tracking.
typedef UInt16 MouseTrackingResult;
enum {
kMouseTrackingMouseDown = 1,
kMouseTrackingMouseUp = 2,
kMouseTrackingMouseExited = 3,
kMouseTrackingMouseEntered = 4,
kMouseTrackingMouseDragged = 5,
kMouseTrackingKeyModifiersChanged = 6,
kMouseTrackingUserCancelled = 7,
kMouseTrackingTimedOut = 8,
kMouseTrackingMouseMoved = 9
};
Constants
kMouseTrackingMouseDownThe user pressed any mouse button.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseUpThe user released the mouse button.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseExitedThe mouse exited the specified region.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseEnteredThe mouse entered the specified region.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseDraggedThe mouse moved while the mouse button was down.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kMouseTrackingKeyModifiersChangedOne or more keyboard modifiers (option, control, and so on) for the mouse changed.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kMouseTrackingMouseMovedPrior to Mac OS X v10.2, this constant was equivalent to
kMouseTrackingMouseDragged. In Mac OS X v10.2 and later,kMouseTrackingMouseMovedindicates that the mouse moved while the mouse button was up.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
These constants are returned by TrackMouseLocation and TrackMouseRegion, which are designed as replacements to calls such as StillDown and WaitMouseUp. The advantage over those routines is that TrackMouseLocation and TrackMouseRegion block if the user is not moving the mouse, whereas mouse tracking loops based on StillDown and WaitMouseUp spin, chewing up valuable CPU time that could be better spent elsewhere. It is highly recommended that any tracking loops in your application stop using StillDown and WaitMouseUp and start using TrackMouseLocation or TrackMouseRegion. See the notes on those functions for more information.
Mouse Tracking Selectors
Define a constant for “sticky” mode used by the HIMouseTrackingGetParameters function.
enum {
kMouseParamsSticky = 'stic'
};
Constants
kMouseParamsStickyRequests the time and distance for determining “sticky” mouse tracking. When the mouse is clicked on a menu title, the toolbox enters a sticky mouse-tracking mode that varies according to the time and distance between the mouse-down event and the mouse-up event. In this mode, the menu is tracked even though the mouse has already been released.
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Services Manager Constants
Services Manager Events
Define constants related to Services Manager events.
enum {
kEventServiceCopy = 1,
kEventServicePaste = 2,
kEventServiceGetTypes = 3,
kEventServicePerform = 4
};
Constants
kEventServiceCopyThe user wants to invoke a service that requires your application to provide data. Your application must update the scrap reference in the
kEventParamScrapRefparameter to indicate the appropriate data from the current selection or user focus. See the Discussion section for additional information about this parameter for Mac OS X v10.3 and later.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventServicePasteThe user has invoked a service that requires your application to receive data. Your application must update the current user focus with the data provided by the
kEventParamScrapRefparameter. See the Discussion section for additional information about this parameter for Mac OS X v10.3 and later.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventServiceGetTypesSent when the Services Manager needs to know what types of data it can cut-and-paste into the scrap. The Services Manager uses this information to update the Services menu, indicating which services are available for the current selection. This event passes two
CFMutableArrayreferences to you in thekEventParamServiceCopyTypesandkEventParamServicePasteTypesparameters. You should fill out these arrays with Core Foundation strings indicating which types your application can copy and paste. Note that you can use theCreateTypeStringWithOSTypeto create aCFStringReffrom anOSType.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventServicePerformSent when your application must perform a service. The
kEventParamScrapRefparameter holds the scrap information, and thekEventParamServiceMessageNameparameter contains a Core Foundation string indicating what service was requested. Only applications that can provide services receive this event. See the Discussion section for additional information about this parameter for Mac OS X v10.3 and later.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.
Discussion
In Mac OS X 10.3 and later, the kEventServiceCopy, kEventServicePaste, and kEventServicePerform events include a PasteboardRef and a ScrapRef. A handler for this event should provide its data using either Pasteboard or Scrap Manager APIs, and the corresponding pasteboard or scrap reference, depending on which is more convenient or appropriate. Data only needs to be placed on one of the pasteboard or scrap; it does not need to be placed on both. Data written to the pasteboard is also be available on the scrap, and vice versa.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Services Manager Event Parameters
Define constants for parameters to Service Manager events.
enum {
kEventParamScrapRef = 'scrp',
kEventParamServiceCopyTypes = 'svsd',
kEventParamServicePasteTypes = 'svpt',
kEventParamServiceMessageName = 'svmg',
kEventParamServiceUserData = 'svud',
typeScrapRef = 'scrp',
typeCFMutableArrayRef = 'cfma'
};
Constants
kEventParamScrapRefWhen provided as a parameter to the
kEventServicePasteevent, the current selection should be replaced by data from this scrap. When provided as a parameter tokEventServicePerform, the scrap that should be used to send and receive data from the requester. When provided as a parameter to thekEventServiceCopyevent, data from the current selection should be placed into this scrap.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamServiceCopyTypesWhen provided as a parameter to the
kEventServiceGetTypesevent, add CFString references to this array to report the types that can be pasted from the current selection. These strings will be released automatically after the event is handled.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamServicePasteTypesWhen provided as a parameter to the
kEventServiceGetTypesevent, add CFString references to this array to report the types that can be copied from the current selection. These strings will be released automatically after the event is handled.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamServiceMessageNameWhen provided as a parameter to the
kEventServicePerformevent, contains the name of the advertised service that was invoked.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamServiceUserDataWhen provided as a parameter to the
kEventServicePerformevent, contains extra data provided by the requestor.Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.
Tablet Event Constants
Tablet Events
Define constants for events related to drawing tablets.
enum {
kEventTabletPoint = 1,
kEventTabletProximity = 2,
kEventTabletPointer = 1
};
Constants
kEventTabletPointIndicates that the pen has moved on a tablet. (Mac OS X only)
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventTabletProximityIndicates that the pen has entered the proximity region of the tablet. (Mac OS X only)
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTabletPointerSame as
kEventTabletPoint. This deprecated constant is here for compatibility only.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Tablet Event Parameters
Define constants for parameters to table events.
enum {
kEventParamTabletPointRec = 'tbrc',
kEventParamTabletProximityRec = 'tbpx',
typeTabletPointRec = 'tbrc',
typeTabletProximityRec = 'tbpx',
kEventParamTabletPointerRec = 'tbrc',
typeTabletPointerRec = 'tbrc'
};
Constants
kEventParamTabletPointRectypeTabletPointRec
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamTabletProximityRectypeTabletProximityRec
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeTabletPointReckEventParamTabletPointRec
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.typeTabletProximityReckEventParamTabletProximityRec
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTabletPointerRectypeTabletPointerRec
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeTabletPointerReckEventParamTabletPointerRec
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Text Input Events
Text Input Event Constants
Define constants related to events from kEventClassTextInput.
enum {
kEventTextInputUpdateActiveInputArea = 1,
kEventTextInputUnicodeForKeyEvent = 2,
kEventTextInputOffsetToPos = 3,
kEventTextInputPosToOffset = 4,
kEventTextInputShowHideBottomWindow = 5,
kEventTextInputGetSelectedText = 6,
kEventTextInputUnicodeText = 7,
kEventTextInputFilterText = 14
};
Constants
kEventTextInputUpdateActiveInputAreaTells the application text engine to initiate or terminate or manage the content of inline input session.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputUnicodeForKeyEventProvides Unicode text resulting from a key event (in which TSM originates the event) or from a
kEventTextInputUnicodeTextevent produced by an input method, such as the Character Palette class input method, or a Handwriting input method. A client need not be fully TSM-aware to process or receive this event, which has become the standard way of getting Unicode text from key events. You can also get Mac encoding characters from the raw keyboard event contained in this event. If noUnicodeForKeyEventhandler is installed, and nokUnicodeNotFromInputMethodAppleEvent handler is installed (or the application has not created a Unicode TSMDocument), the Mac encoding charCodes (if these can be converted from the Unicodes) are provided toWaitNextEvent. This event is generated automatically by TSM when akEventRawKeyDownevent is sent to the application event target. The typical keyboard event flow begins with akEventRawKeyDownevent posted to the event queue. This event is dequeued duringWaitNextEventorRunApplicationEventLoop, and sent to the event dispatcher target. If the key down event reaches the application target, it is handled by TSM, which generates akEventTextInputUnicodeForKeyEventevent and sends it to the event dispatcher target. The event dispatcher resends the event to the user focus target, which sends it to the focused window.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputOffsetToPosConvert from inline session text offset to global QD Point. This event is typically produced by an input method so that it can best position a palette “near” the text being operated on by the user.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputPosToOffsetConvert from global QD point to inline session text offset. This event is typically produced by an input method to perform proper cursor management as the cursor moves over various subranges, or clauses of text (or the boundaries between these) in the inline input session.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputShowHideBottomWindowShow/Hide the bottom line input window. This event is produced by Input Methods to control the Text Services Manager bottom-line input window, and is not normally handled by an application.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputGetSelectedTextGet the selected text (or the character before or after the insertion point, based on the value of the
leadingEdgeparameter) from the application’s text engine.)Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventTextInputUnicodeTextProduced only by input methods or other text services and is delivered to the Text Services Manager by
SendTextInputEvent. The Text Services Manager does not dispatch this event to the user focus, so application handlers should not install handlers for this event. Instead, the Text Services Manager chains this event into any active keyboard input method in order to prevent interference with existing inline input sessions. The keyboard input method can either insert the text into the inline session or confirm its session and return theUnicodeTextevent to the Text Services Manager unhandled, in which case the Text Services Manager converts the event into aUnicodeForKeyevent (converting the Unicodes to Mac character codes and synthesizing information where needed) and finally dispatch the resulting event to the user focus as usual.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventTextInputFilterTextSent before any final-form text is sent to the user focus. Final form text includes text produced by a keyboard layout, Ink input method, Character palette or any other Text Services Manager text service, and any text being “confirmed” (or committed) from an inline input session. In the case of text confirmed from an inline input session, the Text Services Manager takes the resulting text buffer filtered by the event handler and adjusts all parameters in the
UpdateActiveInputAreaevent produced by the input method. The text filtering action is thus transparent to both the application’sUpdateActiveInputAreahandler and the input method confirming the text.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Discussion
The following text input events re-implement the Apple events defined in the Text Services Manager Reference, and provide the benefits of Carbon event targeting, dispatching and propagation to applications that have formerly handled the Text Services Manager suite of Apple events. You can install text input handlers on controls, windows, or the application event target (which is equivalent to Apple-event-based handling). In all cases, if a given text input handler is not installed, the Text Services Manager converts the event into an AppleEvent and re-dispatches it via AESend to the current process, making adoption as gradual as is desired.
Table 10 shows the parameters related to text input events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Deprecated Text Input Constants
Define deprecated text input events.
enum {
kEventUpdateActiveInputArea = kEventTextInputUpdateActiveInputArea,
kEventUnicodeForKeyEvent = kEventTextInputUnicodeForKeyEvent,
kEventOffsetToPos = kEventTextInputOffsetToPos,
kEventPosToOffset = kEventTextInputPosToOffset,
kEventShowHideBottomWindow = kEventTextInputShowHideBottomWindow,
kEventGetSelectedText = kEventTextInputGetSelectedText
};
Constants
kEventUpdateActiveInputAreaEquivalent to
kEventTextInputUpdateActiveInputArea.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventUnicodeForKeyEventEquivalent to
kEventTextInputUnicodeForKeyEvent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventOffsetToPosEquivalent to
kEventTextInputOffsetToPos.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventPosToOffsetEquivalent to
kEventTextInputPosToOffset.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventShowHideBottomWindowEquivalent to
kEventTextInputShowHideBottomWindow.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventGetSelectedTextEquivalent to
kEventTextInputGetSelectedText.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
These constants are superseded by constants described in “Text Input Event Constants” and are included for backwards compatibility.
Text Input Event Parameters
Define constants for parameters to text input events.
enum {
kEventParamTextInputSendRefCon = 'tsrc',
kEventParamTextInputSendComponentInstance = 'tsci',
kEventParamTextInputSendSLRec = 'tssl',
kEventParamTextInputReplySLRec = 'trsl',
kEventParamTextInputSendText = 'tstx',
kEventParamTextInputReplyText = 'trtx',
kEventParamTextInputSendUpdateRng = 'tsup',
kEventParamTextInputSendHiliteRng = 'tshi',
kEventParamTextInputSendClauseRng = 'tscl',
kEventParamTextInputSendPinRng = 'tspn',
kEventParamTextInputSendFixLen = 'tsfx',
kEventParamTextInputSendLeadingEdge = 'tsle',
kEventParamTextInputReplyLeadingEdge = 'trle',
kEventParamTextInputSendTextOffset = 'tsto',
kEventParamTextInputReplyTextOffset = 'trto',
kEventParamTextInputReplyRegionClass = 'trrg',
kEventParamTextInputSendCurrentPoint = 'tscp',
kEventParamTextInputSendDraggingMode = 'tsdm',
kEventParamTextInputReplyPoint = 'trpt',
kEventParamTextInputReplyFont = 'trft',
kEventParamTextInputReplyFMFont = 'trfm',
kEventParamTextInputReplyPointSize = 'trpz',
kEventParamTextInputReplyLineHeight = 'trlh',
kEventParamTextInputReplyLineAscent = 'trla',
kEventParamTextInputReplyTextAngle = 'trta',
kEventParamTextInputSendShowHide = 'tssh',
kEventParamTextInputReplyShowHide = 'trsh',
kEventParamTextInputSendKeyboardEvent = 'tske',
kEventParamTextInputSendTextServiceEncoding = 'tsse',
kEventParamTextInputSendTextServiceMacEncoding = 'tssm',
kEventParamTextInputGlyphInfoArray = 'glph',
kEventParamTextInputSendGlyphInfoArray = kEventParamTextInputGlyphInfoArray,
kEventParamTextInputReplyGlyphInfoArray = 'rgph',
kEventParamTextInputSendReplaceRange = 'tsrp'
};
Constants
kEventParamTextInputSendRefContypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendComponentInstancetypeComponentInstance
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendSLRectypeIntlWritingCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplySLRectypeIntlWritingCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendTexttypeUnicodeText (if TSMDocument is Unicode), otherwise typeChar
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyTexttypeUnicodeText (if TSMDocument is Unicode), otherwise typeChar
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendUpdateRngtypeTextRangeArray
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendHiliteRngtypeTextRangeArray
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendClauseRngtypeOffsetArray
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendPinRngtypeTextRange
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendFixLentypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendLeadingEdgetypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyLeadingEdgetypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendTextOffsettypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyTextOffsettypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyRegionClasstypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendCurrentPointtypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendDraggingModetypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyPointtypeQDPoint
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyFonttypeLongInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyFMFonttypeUInt32
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyPointSizetypeFixed
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyLineHeighttypeShortInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyLineAscenttypeShortInteger
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyTextAngletypeFixed
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendShowHidetypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyShowHidetypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendKeyboardEventtypeEventRef
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendTextServiceEncodingtypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendTextServiceMacEncodingtypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamTextInputReplyGlyphInfoArraytypeGlyphInfoArray
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTextInputSendReplaceRangetypeCFRange
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Text Service Manager Document Events
Text Service Manager Document Event Parameters
Define constants for Text Service Manager Document event parameters and types.
enum {
kEventParamTSMDocAccessSendRefCon = kEventParamTSMSendRefCon,
kEventParamTSMDocAccessSendComponentInstance = kEventParamTSMSendComponentInstance,
kEventParamTSMDocAccessCharacterCount = 'tdct',
kEventParamTSMDocAccessReplyCharacterRange = 'tdrr',
kEventParamTSMDocAccessReplyCharactersPtr = 'tdrp',
kEventParamTSMDocAccessSendCharacterIndex = 'tdsi',
kEventParamTSMDocAccessSendCharacterRange = 'tdsr',
kEventParamTSMDocAccessSendCharactersPtr = 'tdsp',
kEventParamTSMDocAccessRequestedCharacterAttributes = 'tdca',
kEventParamTSMDocAccessReplyATSFont = 'tdaf',
kEventParamTSMDocAccessReplyFontSize = 'tdrs',
kEventParamTSMDocAccessEffectiveRange = 'tder',
kEventParamTSMDocAccessReplyATSUGlyphSelector = 'tdrg',
kEventParamTSMDocAccessLockCount = 'tdlc',
kEventParamTSMDocAccessLineBounds = 'tdlb',
typeATSFontRef = 'atsf',
typeGlyphSelector = 'glfs'
};
Constants
kEventParamTSMDocAccessSendRefContypeLongInteger
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessSendComponentInstancetypeComponentInstance
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessCharacterCounttypeCFIndex
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessReplyCharacterRangetypeCFRange
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessReplyCharactersPtrtypePtr
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessSendCharacterIndextypeCFIndex
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessSendCharactersPtrtypePtr
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessRequestedCharacterAttributestypeUInt32
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessReplyATSFonttypeATSFontRef
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessReplyFontSizetypeFloat
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessEffectiveRangetypeRange
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessReplyATSUGlyphSelectortypeGlyphSelector
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessLockCounttypeCFIndex
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamTSMDocAccessLineBoundstypeCFMutableArrayRef
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.typeATSFontRefATSFontRef
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.typeGlyphSelectorATSUGlyphSelector
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Timer Constants
Idle Timer Event Constants
Define constants used for timer events.
enum {
kEventLoopIdleTimerStarted = 1,
kEventLoopIdleTimerIdling = 2,
kEventLoopIdleTimerStopped = 3
};
Constants
kEventLoopIdleTimerStartedThe idle period has just begun (and this is the first time your callback is being called for this idle period).
Available in OS X v10.2 and later.
Declared in
CarbonEventsCore.h.kEventLoopIdleTimerIdlingThe idle period is continuing.
Available in OS X v10.2 and later.
Declared in
CarbonEventsCore.h.kEventLoopIdleTimerStoppedThe idle period has just stopped (a user event occurred). Your callback should do any necessary cleanup of the idle process now that a user event has occurred.
Available in OS X v10.2 and later.
Declared in
CarbonEventsCore.h.
Discussion
These constants are passed to your idle timer callback function. For more information, see the InstallEventLoopIdleTimer function.
Toolbar Events
Toolbar Event Parameters
Define constants for parameters to toolbar events.
enum {
kEventParamToolbar = 'tbar',
kEventParamToolbarItem = 'tbit',
kEventParamToolbarItemIdentifier = 'tbii',
kEventParamToolbarItemConfigData = 'tbid',
typeHIToolbarRef = 'tbar',
typeHIToolbarItemRef = 'tbit'
};
Constants
kEventParamToolbartypeHIToolbarRef
Available in OS X v10.2 and later.
Declared in
HIToolbar.h.kEventParamToolbarItemtypeHIToolbarItemRef
Available in OS X v10.2 and later.
Declared in
HIToolbar.h.kEventParamToolbarItemIdentifiertypeHIToolbarRef
Available in OS X v10.2 and later.
Declared in
HIToolbar.h.kEventParamToolbarItemConfigDatatypeCFStringRef
Available in OS X v10.2 and later.
Declared in
HIToolbar.h.
Discussion
For details about toolbar events and event parameters, see HIToolbar Referencein the User Experience section of the Carbon documentation.
Volume Events
Volume Event Constants
Define constants related to events from kEventClassVolume.
enum {
kEventVolumeMounted = 1,
kEventVolumeUnmounted = 2
};
Constants
kEventVolumeMountedNew volume (hard drive or removable media) mounted.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventVolumeUnmountedVolume has been ejected or unmounted.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Volume Reference Constant
Define the type of a volume reference.
enum {
typeFSVolumeRefNum = 'voln'
};
Constants
typeFSVolumeRefNumAn
FSVolumeRefNumidentifying the volume that was mounted or unmounted.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Window Events
Window Action Event Constants
Define constants related to events from kEventClassWindow.
enum {
kEventWindowCollapse = 66,
kEventWindowCollapseAll = 68,
kEventWindowExpand = 69,
kEventWindowExpandAll = 71,
kEventWindowClose = 72,
kEventWindowCloseAll = 74,
kEventWindowZoom = 75,
kEventWindowZoomAll = 77,
kEventWindowContextualMenuSelect = 78,
kEventWindowPathSelect = 79,
kEventWindowGetIdealSize = 80,
kEventWindowGetMinimumSize = 81,
kEventWindowGetMaximumSize = 82,
kEventWindowConstrain = 83,
kEventWindowHandleContentClick = 85,
kEventWindowTransitionStarted = 88,
kEventWindowTransitionCompleted = 89,
kEventWindowGetDockTileMenu = 90,
kEventWindowGetDockTileMenu = 90,
kEventWindowProxyBeginDrag = 128,
kEventWindowProxyEndDrag = 129,
kEventWindowToolbarSwitchMode = 150
};
Constants
kEventWindowCollapseIf the window is not collapsed, this event is sent by the standard window handler after it has received
kEventWindowClickCollapseRgnand receivedtruefrom a call toTrackBox. The default behavior is to callCollapseWindowand then sendkEventWindowCollapsedif no error is received fromCollapseWindow.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowCollapseAllSent by the standard window handler (when the option key is down) after it has received
kEventWindowClickCollapseRgnand then received true from a call toTrackBox. The default response is to send each window of the same class as the clicked window akEventWindowCollapseevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowExpandIf the window is collapsed, this event is sent by the standard window handler after it has received
kEventWindowClickCollapseRgnand received true from a call toTrackBox. The default response is to callCollapseWindow, then sendkEventWindowExpanded. Note that you will not receive this event before a window is expanded from the dock, since minimized windows in the dock don’t uses collapse boxes to unminimize.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowExpandAllSent by the standard window handler (when the option key is down) after it has received
kEventWindowClickCollapseRgnand then received true from a call toTrackBox. The default response is to send each window of the same class as the clicked window akEventWindowExpandevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowCloseSent by the standard window handler after it has received
kEventWindowClickCloseRgnand successfully calledTrackBox. Your application might intercept this event to check if the document is dirty, and display a Save/Don’t Save/Cancel alert.The default response is to call the Window Manager function
DisposeWindow.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowCloseAllSent by the standard window handler (when the option key is down) after it has received
kEventWindowClickCloseRgnand received true from a call toTrackGoAway. The standard window handler’s response is to send each window with the same class as the clicked window akEventWindowCloseevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowZoomSent by the standard window handler upon receiving
kEventWindowClickZoomRgnand then receiving true from a call toTrackBox. The default behavior is to zoom the window usingZoomWindowIdealthen, if successful, send akEventWindowZoomedevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowZoomAllSent by the standard window handler (when the option key is down) after it has received
kEventObjectClickZoomRgnand received true from a call toTrackBox. The standard window handler’s response is to send each window with the same class as the clicked window akEventObjectZoomevent and then to reposition all zoomed windows using thekWindowCascadeOnParentWindowScreenpositioning method. For more details, see the Window Manager Reference for more details.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowContextualMenuSelectSent when either the right mouse button is pressed, or the control key is held down and the left mouse button is pressed, or the left mouse button is held down for more than 1/4th of a second (and nothing else is handling the generated mouse tracking events). The standard window handler ignores this event. Note that this event supports
kEventParamMouseLocationand other parameters associated with thekEventMouseDownevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowPathSelectSent when the Window Manager function
IsWindowPathSelectClickwould return true. The standard window handler sends this event while handlingkEventWindowClickDragRgnif the click occurs in the proxy icon. Set the menu reference parameter (kEventParamMenuRef) in the event if you wish to customize the menu passed to the Window Manager functionWindowPathSelect.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetIdealSizeSent by the standard window handler to determine the standard state for zooming. The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetMinimumSizeSent by the standard window handler to determine the minimum size of the window (used during window resizing).
In Mac OS X v10.2 and later, the default behavior is to call the Window Manager function
GetWindowResizeLimitsand return the size obtained in thekEventParamDimensionsparameter. There is no default behavior before Mac OS X v10.2.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetMaximumSizeSent by the standard window handler to determine the maximum size of the window (used during window resizing). In Mac OS X v10.2 and later, this event is also sent by the Window Manager functions
ResizeWindowandGrowWindowif thesizeContraintsparameter was set toNULL.In Mac OS X v10.2 and later, the default behavior is to call the Window Manager function
GetWindowResizeLimitsand return the size obtained in thekEventParamDimensionsparameter. There is no default behavior before Mac OS X v10.2.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowConstrainSent by the standard window handler to warn of a change in the available window positioning bounds on the window (for example, due to a change in screen resolution or Dock size).
In Mac OS v10.0 the default behavior is to call the Window Manager function
ConstrainWindowToScreenon the window with thekWindowConstrainMoveRegardlessOfFitattribute set and a window region code ofkWindowDragRgn. The window is constrained to the bounds returned by the Window Manager functionGetAvailableWindowPositioningBoundsfor that display device.In Mac OS X v10.1 and later the default behavior is to call
ConstrainWindowToScreenon the window with thekWindowConstrainMoveRegardlessOfFitandkWindowConstrainAllowPartialattributes set, and a window region code ofkWindowDragRgn. Instead of accepting the normal device bounds, you can also modify thekEventParamAvailableBoundsfor this event, and the default handler constrains the window to those bounds.In Mac OS X v10.2 and later, you can set the following optional parameters:
kEventParamAttributes: You can set the constraint attributes to pass toConstrainWindowToScreenby specifying them in this parameter.kEventParamWindowRegionCode: If you set this parameter (which must be of typeWindowRegionCode), the standard window handler passes this value toConstrainWindowToScreeninstead ofkWindowDragRgn.
In addition, the following optional parameters may exist in Mac OS X v10.2 and later:
kEventParamRgnHandle: Contains the gray region before a configuration change in the available graphics devices (screens). This parameter exists only if the constrain event occurred because the user changed the screen configuration. You can call the Window Manager functionGetGrayRgnto obtain the current gray region.kEventParamCurrentDockRect: Holds the current bounds of the dock. This parameter andkEventParamPreviousDockRectexist only if the constrain event resulted from a change in the Dock size or position.kEventParamPreviousDockRect: Holds the previous bounds of the dock.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowHandleContentClickSent by the standard window handler in response to
kEventWindowClickContentRgnwhen a mouse click is in the content region but is not a contextual menu invocation or a click on a control. Note that this event supportskEventParamMouseLocationand other parameters associated with thekEventMouseDownevent.The standard handler ignores this event.
Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowTransitionStartedSent to all handlers registered for it. It is sent by the
TransitionWindow,TransitionWindowAndParent, andTransitionWindowWithOptionsAPIs just before the first frame of the transition animation.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventWindowTransitionCompletedSent to all handlers registered for it. It is sent by the
TransitionWindow,TransitionWindowAndParent, andTransitionWindowWithOptionsAPIs just after the last frame of the transition animation.Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventWindowGetDockTileMenuSent when a dock tile wants to display a menu. The sender of this event releases the menu after the Dock has displayed it, so if you want to keep the menu, you must call
RetainMenuon it before returning from the event handler.If you do not handle this event, the default behavior is to call the Window Manager function
GetWindowDockTileMenuand return the menu obtained in thekEventParamMenuRefparameter. If no menu is specified, the default handler returnseventNotHandledErr.Note that in most cases it is simpler to call the
SetWindowDockTileMenufunction directly rather than register for this event.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowProxyBeginDragSent before a proxy icon drag; you can attach data to the
DragRefin the event. The standard handler ignores this event.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowProxyEndDragSent after the proxy icon drag is complete, whether successful or not. The standard handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowToolbarSwitchModeThe toolbar button (that is, the oblong button used to show and hide the toolbar) was successfully clicked. The standard window handler sends this event when receiving a
truereturn value fromTrackBoxduring the handling of thekEventWindowClickToobarButtonRgnevent. Note, however, that you do not have to have the standard window handler installed to receive this event; any window that has a toolbar receives this event when its toolbar button is successfully clicked. Note that if you handle this event, your application is responsible for keeping track of the toolbar’s mode (visible or hidden).The default response is to toggle the toolbar (that is, show it if it is hidden, and vice-versa) when the toolbar button is clicked. If the option key is held down during the click, all toolbars in the windows of the current process are toggled. If the command key is down during the click, the toolbar mode is cycled between icons and text, icons alone, and text alone. If both the command and option keys are held during the click, the system displays the toolbar configuration sheet.
Available in OS X v10.1 and later.
Declared in
CarbonEvents.h.
Discussion
These events indicate that certain changes have been made to a window. These events have greater semantic meaning than the low-level window click events and are usually preferred for overriding.
Table 11 shows the parameters related to window action events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other parameters from |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other parameters from |
||
|
|
|
|
|
|
|
|
|
Window Activation Event Constants
Define constants related to events from kEventClassWindow that specify whether a window is activated or deactivated.
enum {
kEventWindowActivated = 5,
kEventWindowDeactivated = 6,
kEventWindowHandleActivate = 91,
kEventWindowHandleDeactivate = 92
kEventWindowGetClickActivation = 7,
kEventWindowGetClickModality = 8
};
Constants
kEventWindowActivatedThe window is active now. Sent to any window that is activated, regardless of whether the window has the standard window handler installed.
In Mac OS X v10.3 and later, the standard window handler responds to this event by sending a
kEventWindowHandleActivateevent to the window. On earlier releases of Mac OS X and CarbonLib, the standard window handler callsActivateControlon the window’s root control.Note that this event is sent directly to the window target. If no handler takes the event (that is, they all return
eventNotHandledErr), then the Window Manager posts this event to the event queue. Doing so allows the Carbon Event Manager to convert the event into an old-style event record (EventRecord), to be returned fromWaitNextEvent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDeactivatedThe window is inactive now. Sent to any window that is deactivated, regardless of whether the window has the standard window handler installed.
In Mac OS X v10.3 and later, the standard window handler responds to this event by sending a
kEventWindowHandleDeactivateevent to the window. On earlier releases of Mac OS X and CarbonLib, the standard window handler callsDeactivateControlon the window’s root control.Note that this event is sent directly to the window target. If no handler takes the event (that is, they all return
eventNotHandledErr), then the Window Manager posts this event to the event queue. Doing so allows the Carbon Event Manager to convert the event into an old-style event record (EventRecord), to be returned fromWaitNextEvent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowHandleActivateThe window has received a
kEventWindowActivatedevent, and its contents should become active. This event is generated by the standard window handler in response to akEventWindowActivatedevent. You can handle this event by activating the window’s content appropriately. The standard window handler responds to this event by callingActivateControlon the window’s root control.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventWindowHandleDeactivateThe window has received a
kEventWindowDeactivatedevent, and its contents should become inactive. This event is generated by the standard window handler in response to akEventWindowDeactivatedevent. You can handle this event by deactivating the window’s content appropriately. The standard window handler responds to this event by callingDeactivateControlon the window’s root control.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventWindowGetClickActivationSent when a click occurs in a background window that has the standard window handler installed.
The default behavior is to bring the window forward and absorb the click (that is, the mouse click is not passed on to the window). In addition, the appropriate click activation part code is returned in the
kEventParamClickActivationResultparameter. You can use this event to override this behavior and implement click-through.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetClickModalitySent to a window by the event dispatcher target before dispatching a mouse-down or mouse-up event to the clicked window. A handler for this event may examine application state to determine whether this click should be allowed. This event may also be sent in circumstances other than a mouse event:
In
SelectWindowWhen handling the cmd-~ key sequence
When restoring a collapsed window from the Dock
When handling the
kHICommandSelectWindowcommandWhen activating a clicked window during application activation,
In each case, the result of this event is used to determine whether z-ordering, activation, and highlighting of the window should be allowed.
This event contains an optional EventRef parameter that is the original mouse event. If the parameter is not present, the handler should generally assume that the click was a single click.
A default handler for this event is installed on the application target. The default handler determines whether this is a modal click by examining the modality of the visible, uncollapsed windows in front of the clicked window, the location of the click, and the keyboard modifiers. A custom handler may, of course, entirely ignore window z-order or modality, and determine modality in any way it deems necessary.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Discussion
Events related to activating and deactivating a window.
Table 12 shows the parameters related to window activation events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window Click Event Constants
Define constants related to events from kEventClassWindow occurring in the standard window controls or regions (close, resize, drag, and so on).
enum {
kEventWindowClickDragRgn = 32,
kEventWindowClickResizeRgn = 33,
kEventWindowClickCollapseRgn = 34,
kEventWindowClickCloseRgn = 35,
kEventWindowClickZoomRgn = 36,
kEventWindowClickContentRgn = 37,
kEventWindowClickProxyIconRgn = 38,
kEventWindowClickToolbarButtonRgn = 41,
kEventWindowClickStructureRgn = 42
};
Constants
kEventWindowClickDragRgnSent when the mouse is down in the drag region. The standard window handler calls
DragWindow.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickResizeRgnSent when the mouse is down in the resize area. The standard window handler calls
ResizeWindow.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickCollapseRgnSent when the mouse is down in the collapse widget. The default behavior is to call
CollapseWindow, and then generatekEventWindowExpandorkEventWindowCollapse(whichever is the opposite of the window’s original collapse state).Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickCloseRgnSent when the mouse is down in the close widget. The standard window handler calls
TrackGoAway, and then generateskEventWindowClose.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickZoomRgnSent when the mouse is down in the zoom widget. The standard window handler calls
TrackBox, and then generateskEventWindowZoom.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickContentRgnSent when the mouse is down in the content region. The standard window handler checks for contextual menu clicks and clicks on controls, and sends
kEventWindowContextualMenuSelect,kEventControlClick, andkEventWindowHandleContentClickevents as appropriate.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickProxyIconRgnSent when the mouse is down in the proxy icon. The standard window handler handles proxy icon dragging, and generates proxy icon events.
Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowClickToolbarButtonRgnSent when the mouse is down in the toolbar button. The default behavior is to call
TrackBoxand then generate akEventWindowToolbarSwitchModeevent.Available in OS X v10.1 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.
Discussion
Low-level events which generate higher-level “action” events described in “Window Action Event Constants.” These events are generated only for windows with the standard window handler installed. Most clients should allow the standard window handler to implement these events.
Window State Event Constants
Define constants related to events from kEventClassWindow that notify of a change in the window’s state.
enum {
kEventWindowShowing = 22,
kEventWindowHiding = 23,
kEventWindowShown = 24,
kEventWindowHidden = 25,
kEventWindowCollapsing = 86,
kEventWindowCollapsed = 67,
kEventWindowExpanding = 87,
kEventWindowExpanded = 70,
kEventWindowZoomed = 76,
kEventWindowBoundsChanging = 26,
kEventWindowBoundsChanged = 27,
kEventWindowResizeStarted = 28,
kEventWindowResizeCompleted = 29,
kEventWindowDragStarted = 30,
kEventWindowDragCompleted = 31,
kEventWindowClosed = 73
};
Constants
kEventWindowShowingA window is being shown. This is sent inside
ShowHide. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowHidingA window is being hidden. This is sent inside
ShowHide. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowShownThe window has been shown. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowHiddenThe window has been hidden. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowCollapsingThe window is collapsing. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowCollapsedThe object has successfully collapsed. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowExpandingThe window is expanding. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowExpandedThe window has successfully expanded. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowZoomedThe window has been successfully zoomed. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
In CarbonLib 1.1 through 1.4 and Mac OS X prior to v10.2, this event is sent only by the standard window handler after handling
kEventWindowZoom. In CarbonLib 1.5 and later and Mac OS X v10.2 and later, this event is sent by the Window Manager functionsZoomWindowandZoomWindowIdeal.The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowBoundsChangingSent during
DragWindoworResizeWindow, before the window is actually moved or resized. You can alter the current bounds in the event (thekEventParamCurrentBoundsparameter) to change the eventual size and location of the window. Do not call the Window Manager functionsSizeWindoworSetWindowBoundsfrom inside a handler for this event.In Mac OS X v10.1 and later, this event is sent before all changes to a window’s bounds, whether initiated by a user or by a Window Manager call. If the event was sent in response to a user action, the
kWindowBoundsChangeUserDragorkWindowBoundsChangeUserResizeattribute will be set in thekEventParamAttributesparameter.The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowBoundsChangedThe window has been moved or resized (or both). Do not call the Window Manager functions
SizeWindoworSetWindowBoundsfrom inside a handler for this event. If you want to enforce certain window bounds, you should do so from akEventWindowBoundsChangingevent handler.This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
In Mac OS X v10.2 and later, the standard window handler can take this event under the following conditions:
the window uses live resizing (the
kWindowLiveResizeAttributeattribute is set.the user is the one resizing the window
an update event for the window exists in the event queue
If these conditions are met, the standard window handler removes the update event from the event queue and sends it to the event dispatcher target. Doing so simplifies redrawing window content during live resizing.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowResizeStartedThe user has just started to resize a window. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowResizeCompletedThe user has just finished resizing a window. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDragStartedThe user has just started to drag a window. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDragCompletedThe user has completed a window drag. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.
The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowClosedDispatched by
DisposeWindowbefore the window is disposed. This event is propagated to all handlers that registered for the event in the event target’s handler chain, regardless of return value.In CarbonLib 1.5 and earlier and Mac OS X prior to v10.2, if a visible window is destroyed,
kEventWindowClosedis sent before thekEventWindowHiddenevent. In CarbonLib 1.6 and Mac OS X v10.2 and later, thekEventWindowClosedevent is sent afterkEventWindowHidden.The standard window handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
Table 13 shows the parameters related to window state change events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window Refresh Event Constants
Define constants related to window refresh events from kEventClassWindow.
enum {
kEventWindowUpdate = 1,
kEventWindowDrawContent = 2
};
Constants
kEventWindowUpdateLow-level update event. Sent to any window that needs updating regardless of whether the window has the standard window handler installed. You must call the Window Manager function
BeginUpdate, and the QuickDraw functionSetPortbefore drawing your window content, then callEndUpdatewhen you are finished.The standard window handler for this event calls
BeginUpdateandSetPort, sends akEventWindowDrawContentevent to the window, and then callsEndUpdate.Note that this event is sent directly to the window target. If no handler takes the event (that is, they all return
eventNotHandledErr), then the Window Manager posts this event to the event queue. Doing so allows the Carbon Event Manager to convert the event into an old-style event record (EventRecord), to be returned fromWaitNextEvent.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.kEventWindowDrawContentHigher-level update event sent only if you have the standard window handler installed. Functions exactly as
kEventWindowUpdate, except that the Carbon Event Manager callsBegin/EndUpdateandSetPortfor you. All you need to do is draw the window content.The standard window handler calls
DrawControlsfor this window.Available in OS X v10.0 and later.
Not available to 64-bit applications.
Declared in
CarbonEvents.h.
Discussion
Events related to drawing a window’s content.
Table 14 shows the parameters related to window refresh events.
Event kind |
Parameter name |
Parameter type |
|---|---|---|
|
|
|
|
|
|
Window Cursor Change Event Constant
Define a constant related to events from kEventClassWindow that specify that the cursor must change.
enum {
kEventWindowCursorChange = 40
};
Constants
kEventWindowCursorChangeSent when the mouse is moving over the content region. This event is used to manage ownership of the cursor. You should only change the cursor if you receive this event; otherwise, someone else needed to adjust the cursor and handled the event (for example, a TSM Input Method when the mouse is over an inline input region).
The standard handler ignores this event.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
Table 15 shows the parameters related to window cursor change events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
Window Focus Event Constants
Define constants related to events from kEventClassWindow that describe changes in the user focus.
enum {
kEventWindowFocusAcquired = 200,
kEventWindowFocusRelinquish = 201,
kEventWindowFocusContent = 202,
kEventWindowFocusToolbar = 203,
kEventWindowFocusDrawer = 204
};
Constants
kEventWindowFocusAcquiredThe user (or some other action) has caused the focus to shift to your window. In response to this, you should focus any control that might need to be focused.
The standard window handler calls the Control Manager function
SetKeyboardFocusto highlight the first control in the window.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowFocusRelinquishThe user has shifted the focus to another window. You should take the necessary steps to unhighlight the focus and so on.
The default behavior is to clear the current keyboard focus.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowFocusContentFocus should be shifted to the main content area of your window. You should set the focus to the content view of your window; if that area already has focus, then do nothing.
If the content area of the window already has focus, the standard handler does nothing. Otherwise, it calls the HIView function
HIViewAdvanceFocusto move the focus to the first control in the content area.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowFocusToolbarFocus should be shifted to the window’s toolbar. You should set the focus to the first item in the toolbar; if the toolbar already has focus, then do nothing.
If the toolbar already has focus, the default behavior is to do nothing. Otherwise, it calls the HIView function
HIViewAdvanceFocusto move the focus to the first control in the toolbar.If the window does not have a toolbar, this event is not handled.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowFocusDrawerFocus should be shifted to the drawer of a window. You should set the focus to the first item in the drawer. If the drawer already has focus, you should move the focus to the next or previous drawer, if any, depending on whether the modifiers parameter contains the shift key modifier. If the focus is not already contained within the drawer, the basic window handler responds to this event by calling
SetUserFocusWindowand sending akEventWindowFocusContentevent to the appropriate drawer.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Discussion
These events are related to focus changes between windows. They are generated by SetUserFocusWindow. Because that function is called by default only by the standard window handler, these events are normally sent only to windows with the standard window handler installed.
Table 16 shows the parameters related to window focus events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window Sheet Event Constants
Define constants for events from kEventClassWindow that describe window sheet changes.
enum {
kEventWindowSheetOpening = 210,
kEventWindowSheetOpened = 211,
kEventWindowSheetClosing = 212,
kEventWindowSheetClosed = 213
};
Constants
kEventWindowSheetOpeningA sheet is opening. This event is sent to the sheet, its parent window, and the application target before the sheet begins to open. An event handler for this event may return
userCanceledErrif the sheet should not be opened. Any other return value is ignored, and the sheet is allowed to open.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventWindowSheetOpenedA sheet has opened. This event is sent to the sheet, its parent window, and the application target after the sheet is fully open.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventWindowSheetClosingA sheet is closing. This event is sent to the sheet, its parent window, and the application target before the sheet begins to close. An event handler for this event may return
userCanceledErrif the sheet should not close. Any other return value is ignored, and the sheet is allowed to close.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventWindowSheetClosedA sheet has closed. This event is sent to the sheet, its parent window, and the application target after the sheet is fully closed.
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Discussion
These events are related to sheet changes. Table 17 shows the parameters related to window sheet events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
Window Drawer Event Constants
Define constants related to events from kEventClassWindow describing window drawer changes.
enum {
kEventWindowDrawerOpening = 220,
kEventWindowDrawerOpened = 221,
kEventWindowDrawerClosing = 222,
kEventWindowDrawerClosed = 223
};
Constants
kEventWindowDrawerOpeningSent to the drawer and its parent window when the drawer is opening. If you don’t want the drawer to open, your handler should return
userCanceledErr.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowDrawerOpenedSent to the drawer and its parent window when the drawer has fully opened.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowDrawerClosingSent to the drawer and its parent window when the drawer is closing. If you don’t want the drawer to close, your handler should return
userCanceledErr.Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventWindowDrawerClosedSent to the drawer and its parent when the drawer has fully closed.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Discussion
Table 18 shows parameters related to window drawer events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
Window Definition Message Constants
Define constants for events that correspond to classic WDEF messages.
enum {
kEventWindowDrawFrame = 1000,
kEventWindowDrawPart = 1001,
kEventWindowGetRegion = 1002,
kEventWindowHitTest = 1003,
kEventWindowInit = 1004,
kEventWindowDispose = 1005,
kEventWindowDragHilite = 1006,
kEventWindowModified = 1007,
kEventWindowSetupProxyDragImage = 1008,
kEventWindowStateChanged = 1009,
kEventWindowMeasureTitle = 1010,
kEventWindowDrawGrowBox = 1011,
kEventWindowGetGrowImageRegion = 1012,
kEventWindowPaint = 1013
};
Constants
kEventWindowDrawFrameSent by the Window Manager when it’s time to draw a window’s structure. This is the replacement to the old
wDrawdefProc message (though it is a special case of the 0 part code indicating to draw the entire window frame).Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDrawPartSent by the Window Manager when it’s time to draw a specific part of a window’s structure, such as the close box. This is typically sent during window tracking.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetRegionSent by the Window Manager when it needs to get a specific region from a window, or when the
GetWindowRegionfunction is called. The region you should modify is sent in thekEventParamRgnHandleparameter.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowHitTestSent when the Window Manager needs to determine what part of a window would be “hit” with a given mouse location in global coordinates. If you handle this event, you should set the
kEventParamWindowDefPartparameter to reflect the part code hit.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowInitSent by the Window Manager when the window is being created. This is a hook to allow you to do any initialization you might need to do. Note that if the window definition changes, you may receive this event more than once. See the
kEventWindowDisposeevent for more information.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDisposeSent by the Window Manager when the window is being disposed. You should dispose of any private data structures associated with the window. Note, however, that receiving this event does not necessarily mean that the window is being destroyed. Sometimes the Window Manager may need to change the window definition (such as when
ChangeWindowAttributesis used to change the appearance of the window). In such cases, the window receives akEventWindowDisposeevent followed by akEventWindowInitevent to disconnect the old window definition and connect the new one.If you want to know when your window is actually being destroyed, you should register for the
kEventWindowClosedevent.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDragHiliteSent by the Window Manager when it is time to draw/erase any drag highlight in the window structure. This is typically sent from within the
HiliteWindowFrameForDragfunction.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowModifiedSent by the Window Manager when it is time to redraw window structure to account for a change in the document modified state. This is typically sent from within the
SetWindowModifiedfunction.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowSetupProxyDragImageSent by the Window Manager when it is time to generate a drag image for the window proxy. This is typically sent from within the
BeginWindowProxyDragfunction.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowStateChangedSent by the Window Manager when a particular window state changes. See the state-change flags in
MacWindows.h.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowMeasureTitleSent when the Window Manager needs to know how much space the window’s title area takes up.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDrawGrowBoxThis is a compatibility event used before Mac OS 8 and not useful now. When the
DrawGrowIconfunction is called, this event is sent to the window to tell it to draw the grow box. This is really needed only for windows that do not have the grow box integrated into the window frame. Scroll bar delimiter lines are also drawn.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowGetGrowImageRegionThis is a special way for a window to override the standard resize outline for windows that do not do live resizing. As the user resizes the window, this event is sent with the current size the user has chosen expressed as a rectangle. You should calculate your window outline and modify the
kEventParamRgnHandleparameter to reflect your desired outline.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowPaintSent when it is time to draw the entire window (such as when the window is first displayed). This is a convenience event that gives you a chance to draw all the window elements at once.
If you do not handle this event, the Window Manager sends the
kEventWindowDrawFrameevent to your window and erases the content region to its background color.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
These events, which correspond to WDEF messages, are sent to all windows, regardless of whether they have the standard window handler installed.
Table 19 shows the parameters related to window definition events.
Event kind |
Parameter name |
Parameter type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Alternate Window Definition Event Constants
Define alternate names for window definition events.
enum {
kEventWindowDefDrawFrame = kEventWindowDrawFrame,
kEventWindowDefDrawPart = kEventWindowDrawPart,
kEventWindowDefGetRegion = kEventWindowGetRegion,
kEventWindowDefHitTest = kEventWindowHitTest,
kEventWindowDefInit = kEventWindowInit,
kEventWindowDefDispose = kEventWindowDispose,
kEventWindowDefDragHilite = kEventWindowDragHilite,
kEventWindowDefModified = kEventWindowModified,
kEventWindowDefSetupProxyDragImage = kEventWindowSetupProxyDragImage,
kEventWindowDefStateChanged = kEventWindowStateChanged,
kEventWindowDefMeasureTitle = kEventWindowMeasureTitle,
kEventWindowDefDrawGrowBox = kEventWindowDrawGrowBox,
kEventWindowDefGetGrowImageRegion = kEventWindowGetGrowImageRegion
};
Constants
kEventWindowDefDrawFrameEquivalent to
kEventWindowDrawFrame.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefDrawPartEquivalent to
kEventWindowDrawPart.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefGetRegionEquivalent to
kEventWindowGetRegion.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefHitTestEquivalent to
kEventWindowHitTest.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefInitEquivalent to
kEventWindowInit.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefDisposeEquivalent to
kEventWindowDispose.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefDragHiliteEquivalent to
kEventWindowDragHilite.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefModifiedEquivalent to
kEventWindowModified.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefSetupProxyDragImageEquivalent to
kEventWindowSetupProxyDragImage.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefStateChangedEquivalent to
kEventWindowStateChanged.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefMeasureTitleEquivalent to
kEventWindowMeasureTitle.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefDrawGrowBoxEquivalent to
kEventWindowDrawGrowBox.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventWindowDefGetGrowImageRegionEquivalent to
kEventWindowGetGrowImageRegion.Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.
Discussion
For clarity, you can use these event names in place of the standard window events when using them in your custom window definitions. For descriptions of these events, see “Window Definition Message Constants.”
Window Bounds Attributes
Define constants that describe how a window’s bounds are changing.
enum {
kWindowBoundsChangeUserDrag = (1 << 0),
kWindowBoundsChangeUserResize = (1 << 1),
kWindowBoundsChangeSizeChanged = (1 << 2),
kWindowBoundsChangeOriginChanged = (1 << 3),
kWindowBoundsChangeZoom = (1 << 4)
};
Constants
kWindowBoundsChangeUserDragThe bounds are changing because the user is dragging the window around.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kWindowBoundsChangeUserResizeThe bounds are changing because the user is resizing the window.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kWindowBoundsChangeSizeChangedThe dimensions of the window (width and height) are changing.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kWindowBoundsChangeOriginChangedThe origin of the window is changing.
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kWindowBoundsChangeZoomThe bounds are changing as a result of the user clicking the zoom button.
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.
Discussion
When the toolbox sends out a kEventWindowBoundsChanging or kEventWindowBoundsChanged event, it also sends along a parameter containing attributes of the event (kEventParamAttributes). You can use these attributes to determine what aspect of the window changed (origin, size, or both), and whether or not some user action is driving the change (drag, resize, or zoom).
Window Event Parameters and Types
Define constants for parameters and attributes related to window events.
enum {
kEventParamWindowFeatures = 'wftr',
kEventParamWindowDefPart = 'wdpc',
kEventParamWindowPartCode = wpar',
kEventParamCurrentBounds = 'crct',
kEventParamOriginalBounds = 'orct',
kEventParamPreviousBounds = 'prct',
kEventParamClickActivation = 'clac',
kEventParamWindowRegionCode = 'wshp',
kEventParamWindowDragHiliteFlag = 'wdhf',
kEventParamWindowModifiedFlag = 'wmff',
kEventParamWindowProxyGWorldPtr = 'wpgw',
kEventParamWindowProxyImageRgn = 'wpir',
kEventParamWindowProxyOutlineRgn = 'wpor',
kEventParamWindowStateChangedFlags = 'wscf',
kEventParamWindowTitleFullWidth = 'wtfw',
kEventParamWindowTitleTextWidth = 'wttw',
kEventParamWindowGrowRect = 'grct',
kEventParamPreviousDockRect = 'pdrc',
kEventParamPreviousDockDevice = 'pdgd',
kEventParamCurrentDockRect = 'cdrc',
kEventParamCurrentDockDevice = 'cdgd',
kEventParamWindowTransitionAction = 'wtac',
kEventParamWindowTransitionEffect = 'wtef',
typeWindowRegionCode = 'wshp',
typeWindowDefPartCode = 'wdpt',
typeClickActivationResult = 'clac',
typeWindowTransitionAction = 'wtac',
typeWindowTransitionEffect = 'wtef'
};
Constants
kEventParamWindowFeaturestypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowDefParttypeWindowDefPartCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowPartCodetypeWindowPartCode
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamCurrentBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamOriginalBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamPreviousBoundstypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamClickActivationtypeClickActivationResult
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowRegionCodetypeWindowRegionCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowDragHiliteFlagtypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowModifiedFlagtypeBoolean
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowProxyGWorldPtrtypeGWorldPtr
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowProxyImageRgntypeQDRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowProxyOutlineRgntypeQDRgnHandle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowStateChangedFlagstypeUInt32
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowTitleFullWidthtypeSInt16
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowTitleTextWidthtypeSInt16
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamWindowGrowRecttypeQDRectangle
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.kEventParamPreviousDockRecttypeHIRect
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamPreviousDockDevicetypeGDHandle
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamCurrentDockRecttypeHIRect
Available in OS X v10.2 and later.
Declared in
CarbonEvents.h.kEventParamCurrentDockDevicetypeGDHandle
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamWindowTransitionActiontypeWindowTransitionAction
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.kEventParamWindowTransitionEffecttypeWindowTransitionEffect
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.typeWindowRegionCodeWindowRegionCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeWindowDefPartCodeWindowDefPartCode
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeWindowPartCodeWindowPartCode
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.typeClickActivationResultClickActivationResult
Available in OS X v10.0 and later.
Declared in
CarbonEvents.h.typeWindowTransitionActionWindowTransitionAction
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.typeWindowTransitionEffectWindowTransitionEffect
Available in OS X v10.3 and later.
Declared in
CarbonEvents.h.
Modal Window Event Parameters and Types
Define constants related to events from kEventClassWindow used to determine whether a mouse-down or mouse-up event is blocked by a modal window.
enum {
typeModalClickResult = 'wmcr',
typeWindowModality = 'wmod',
kEventParamModalClickResult = typeModalClickResult,
kEventParamModalWindow = 'mwin',
kEventParamWindowModality = typeWindowModality
};
Constants
typeModalClickResultHIModalClickResult
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.typeWindowModalityWindowModality
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventParamModalClickResultOn exit, a value indicating how the click should be handled. For details, see “Modal Window Click Constants.”
Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventParamModalWindowOn exit, the modal window that caused the click to be blocked, if any. The sender of this event uses this information to determine which window should be activated if the application is inactive. This parameter is only required if the
kEventParamModalClickResultparameter containskHIModalClickIsModal. If an event handler wants to report that a click has been blocked by modality, but cannot determine which window blocked the click, it is acceptable to either not add this parameter to the event, or to set the parameter to aNULLwindow reference.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kEventParamWindowModalityOn exit, the modality of the modal window that is in front of the clicked window, if any. This parameter is required only if the
kEventParamModalClickResultparameter containskHIModalClickIsModal.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Modal Window Click Constants
Define constants that describe responses to the kEventWindowGetModalityClick event.
typedef UInt32 HIModalClickResult;
enum {
kHIModalClickIsModal = 1 << 0,
kHIModalClickAllowEvent = 1 << 1,
kHIModalClickAnnounce = 1 << 2,
kHIModalClickRaiseWindow = 1 << 3,
};
Constants
kHIModalClickIsModalA modal window prevents the mouse event from being passed to the clicked window. If this bit is set, the
kEventParamModalWindowandkEventParamWindowModalityparameters should be set before the event handler returns. If this bit is clear, normal event handling occurs: the clicked window is typically z-ordered to the top of its window group, activated, becomes the user focus window, and receives the mouse event for further processing.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIModalClickAllowEventIf
kHIModalClickIsModalis set, thekHIModalClickAllowEventflag indicates whether the click event should be allowed to pass to the clicked window. IfkHIModalClickIsModalis not set, the setting ofkHIModalClickAllowEventis ignored.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIModalClickAnnounceIf
kHIModalClickIsModalis set andkHIModalClickAllowEventis not set,kHIModalClickAnnounceindicates whether the caller should announce that the click has been blocked by a modal window using the appropriate UI (typically, by callingSysBeep). IfkHIModalClickIsModalis not set, or ifkHIModalClickAllowEventis set, the setting ofkHIModalClickAnnounceis ignored.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.kHIModalClickRaiseWindowIf
kHIModalClickIsModalandkHIModalClickAllowEventare set,kHIModalClickRaiseWindowindicates whether the clicked window should be z-ordered to the top of its window group. The window is not, however, activated, nor does it become the user focus window. IfkHIModalClickIsModalorkHIModalClickAllowEventis not set,kHIModalClickRaiseWindowis ignored.Available in OS X v10.4 and later.
Declared in
CarbonEvents.h.
Result Codes
The most common result codes returned by the Carbon Event Manager are listed below.
| Result Code | Value | Description |
|---|---|---|
noErr |
0 | No error. Available in OS X v10.0 and later. |
eventAlreadyPostedErr |
-9860 | Returned from Available in OS X v10.0 and later. |
eventTargetBusyErr |
-9861 | The event target you are trying to modify is busy (for example, dispatching an event). Available in OS X v10.1 and later. |
eventClassInvalidErr |
-9862 | This is obsolete and will be removed. Available in OS X v10.0 and later. |
eventClassIncorrectErr |
-9864 | This is obsolete and will be removed. Available in OS X v10.0 and later. |
eventHandlerAlreadyInstalledErr |
-9866 | Returned from Available in OS X v10.0 and later. |
eventInternalErr |
-9868 | A generic error. Available in OS X v10.0 and later. |
eventKindIncorrectErr |
-9869 | This is obsolete and will be removed. Available in OS X v10.0 and later. |
eventParameterNotFoundErr |
-9870 | The piece of data you are requesting from an event is not present. Available in OS X v10.0 and later. |
eventNotHandledErr |
-9874 | This is what you should return from an event handler when your handler has received an event it doesn’t currently want to (or isn’t able to) handle. If you handle an event, you should return noErr from your event handler. Available in OS X v10.0 and later. |
eventLoopTimedOutErr |
-9875 | The event loop has timed out. This can be returned from calls to Available in OS X v10.0 and later. |
eventLoopQuitErr |
-9876 | The event loop was quit, probably by a call to Available in OS X v10.0 and later. |
eventNotInQueueErr |
-9877 | Returned from Available in OS X v10.0 and later. |
eventHotKeyExistsErr |
-9878 | The hot key combination you chose already exists Available in OS X v10.0 and later. |
eventHotKeyInvalidErr |
-9879 | This error code is not currently used. Available in OS X v10.0 and later. |
© 2003, 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-05-01)