Type Method

addLocalMonitorForEventsMatchingMask:handler:

Installs an event monitor that receives copies of events posted to this application before they are dispatched.

Declaration

+ (id)addLocalMonitorForEventsMatchingMask:(NSEventMask)mask handler:(NSEvent * _Nullable (^)(NSEvent *))block;

Parameters

mask

An event mask specifying which events you wish to monitor. See NSEventMask for possible values.

block

The event handler block object. It is passed the event to monitor. You can return the event unmodified, create and return a new NSEvent object, or return nil to stop the dispatching of the event.

Return Value

An event handler object.

Discussion

Your handler will not be called for events that are consumed by nested event-tracking loops such as control tracking, menu tracking, or window dragging; only events that are dispatched through the applications sendEvent: method will be passed to your handler.

Special Considerations

See Also

Monitoring Application Events

addGlobalMonitorForEventsMatchingMask:handler:

Installs an event monitor that receives copies of events posted to other applications.

removeMonitor:

Remove the specified event monitor.