Type Alias

CGEventTapCallBack

A client-supplied callback function that’s invoked whenever an associated event tap receives a Quartz event.

Declaration

typealias CGEventTapCallBack = (CGEventTapProxy, CGEventType, CGEvent, UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>?

Parameters

proxy

A proxy for the event tap. See CGEventTapProxy. This callback function may pass this proxy to other functions such as the event-posting routines.

type

The event type of this event. See CGEventType.

event

The incoming event. This event is owned by the caller, and you do not need to release it.

refcon

A pointer to user-defined data. You specify this pointer when you create the event tap. Several different event taps could use the same callback function, each tap with its own user-defined data.

Discussion

If the event tap is an active filter, your callback function should return one of the following:

  • The (possibly modified) event that is passed in. This event is passed back to the event system.

  • A newly-constructed event. After the new event has been passed back to the event system, the new event will be released along with the original event.

  • NULL if the event passed in is to be deleted.

If the event tap is an passive listener, your callback function may return the event that is passed in, or NULL. In either case, the event stream is not affected.