Instance Property


The associated events mask of a mouse event.


var associatedEventsMask: NSEvent.EventTypeMask { get }


This property pertains to mouse events. It’s used to determine whether the input device issuing the event can simultaneously issue events of type NSEvent.EventType.pressure. This can be useful if you need to determine whether to initiate or begin initiating a pressure-related action when a mouse event occurs.

For example, suppose you are writing a painting app that uses pressure to determine the size of brush stroke to apply. You can use associatedEventsMask to determine whether a mouse-click event is occurring simultaneously with a pressure event. If not, the user may not have pressure-sensitive hardware and you can apply a default size to the brush stroke.

Listing 1

Example usage of the associatedEventMask property

if (event.associatedEventMask & NSEventMaskPressure) {
   self.pressure = 0; // Prepare for pressure events
} else if (event.subtype == NSTabletPointEventSubtype) {
   self.pressure = event.pressure; // For tablets, the pressure value is embedded in the mouse event
} else {
   self.pressure = 1; // The input device does not support pressure sensitivity, so default to full pressure

See Also

Getting Mouse Event Information

class var pressedMouseButtons: Int

Returns the indices of the currently depressed mouse buttons.

class var doubleClickInterval: TimeInterval

Returns the time, in seconds, in which a second mouse click must occur in order to be considered a double click.

class var mouseLocation: NSPoint

Reports the current mouse position in screen coordinates.

var buttonNumber: Int

The button number for a mouse event.

var clickCount: Int

The number of mouse clicks associated with a mouse-down or mouse-up event.