AEGetEventHandler(_:_:_:_:_:)
Gets an event handler from an Apple event dispatch table.
Declaration
func AEGetEventHandler(_ theAEEventClass: AEEventClass, _ theAEEventID: AEEventID, _ handler: UnsafeMutablePointer<AEEventHandlerUPP?>!, _ handlerRefcon: UnsafeMutablePointer<SRefCon?>!, _ isSysHandler: Bool) -> OSErrParameters
- theAEEventClass:
The event class for the desired handler. See Aeeventclass.
- theAEEventID:
The event ID for the desired handler. See Aeeventid.
- handler:
A universal procedure pointer. On return, a pointer to the specified handler, if a dispatch table entry exists that exactly matches the values supplied in the parameters
theAEEventClassandtheAEEventID.If you use the
typeWildCardconstant for either or both of these parameters,AEGetEventHandlerwill return an error unless an entry exists that specifiestypeWildCardin exactly the same way. For example, if you specifytypeWildCardin both thetheAEEventClassparameter and thetheAEEventIDparameter, the Apple Event Manager will not return the first handler for any event class and event ID in the dispatch table; instead, it will only return a handler if an entry exists that specifies typetypeWildCardfor both the event class and the event ID.For an explanation of wildcard values, see the Discussion section for 1448596 Aeinstalleventhandler.
See Aeeventhandlerupp.
- handlerRefcon:
A pointer to a reference constant. On return, the reference constant from the dispatch table entry for the specified handler. The reference constant may have a value of 0.
- isSysHandler:
Specifies the Apple event dispatch table to get the handler from. Pass
TRUEto get the handler from the system dispatch table orFALSEto get the handler from your application’s dispatch table. See Version Notes for related information.
Return Value
A result code. See Result Codes.
Discussion
Thread safe starting in OS X v10.2.
Your application should not install a handler in a system dispatch table with the goal that the handler will get called when other applications receive events—this won’t work in macOS. For more information, see The System Dispatch Table in Apple Event Dispatching in Apple Events Programming Guide.
In Mac OS 7.1 through 9.x and macOS version v10.2 and later, AEGetEventHandler returns errAEHandlerNotInstalled when there’s not an exact match, even if a wildcard handler is installed that could handle the event. macOS version v10.0.x and v10.1.x will return the wildcard handler.