Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSEventMonitorMBS class.

NSEventMonitorMBS.addGlobalMonitorForEventsMatchingMask(mask as UInt64) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Installs an event monitor that receives copies of events posted to other applications.

mask: An event mask specifying which events you wish to monitor. See NSEventMBS constants for possible values.

Events are delivered asynchronously to your app and you can only observe the event; you cannot modify or otherwise prevent the event from being delivered to its original target application.

Key-related events may only be monitored if accessibility is enabled or if your application is trusted for accessibility access (see AXIsProcessTrusted).

Note that your handler will not be called for events that are sent to your own application.

Special Considerations
In OS X v 10.6, event monitors are only able to monitor the following event types:

NSLeftMouseDragged
NSRightMouseDragged
NSOtherMouseDragged
NSLeftMouseUp
NSRightMouseUp
NSOtherMouseUp
NSLeftMouseDown
NSRightMouseDown
NSOtherMouseDown
NSMouseMoved
NSFlagsChanged
NSScrollWheel
NSTabletPoint
NSTabletProximity
NSKeyDown (Key repeats are determined by sending the event an isARepeat message.)

Available in OS X v10.6 and later.

Some examples using this method:

NSEventMonitorMBS.addLocalMonitorForEventsMatchingMask(mask as UInt64) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Installs an event monitor that receives copies of events posted to this application before they are dispatched.

mask: An event mask specifying which events you wish to monitor. See NSEventMBS constants for possible values.

Calls the LocalEvent event. You can return the event unmodified, create and return a new NSEventMBS object, or return nil to stop the dispatching of the event.

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.

Note: The monitor Block is called for all future events that match mask.

Special Considerations
In OS X v 10.6, event monitors are only able to monitor the following event types:

NSFlagsChanged
NSLeftMouseDragged
NSRightMouseDragged
NSOtherMouseDragged
NSLeftMouseUp
NSRightMouseUp
NSOtherMouseUp
NSLeftMouseDown
NSRightMouseDown
NSOtherMouseDown
NSMouseMoved
NSFlagsChanged
NSScrollWheel
NSTabletPoint
NSTabletProximity
NSKeyDown (Key repeats are determined by sending the event an isARepeat message.)

Available in OS X v10.6 and later.

Some examples using this method:

NSEventMonitorMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The constructor.

Initializes the object.

NSEventMonitorMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacFrameworks Plugin 12.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The destructor.

Remove all event monitors you added.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...