A discrete gesture recognizer that tracks whether the user held down a mouse button for a minimum amount of time before releasing it.


class NSPressGestureRecognizer : NSGestureRecognizer


Use a press gesture recognizer to configure which button must be held and the amount of time for which it must be held. You can also specify how far the mouse is allowed to move and still be considered a valid gesture.

Upon creation, the gesture recognizer is configured to recognize press gestures involving only the primary button. It also delays sending primary button events to the view by setting the delaysPrimaryMouseButtonEvents property to true. To change the set of buttons to track, modify the buttonMask property.


Configuring the Gesture Recognizer

var buttonMask: Int

A bit mask of the button (or buttons) required to recognize this press.

var minimumPressDuration: TimeInterval

The minimum time (in seconds) that the mouse button must be held down in the view for the gesture to be recognized.

var allowableMovement: CGFloat

The maximum movement of the mouse in the view before the gesture fails.

Instance Properties

var numberOfTouchesRequired: Int

The number of touches required in an NSTouchBar object for the gesture recognizer to match.


Inherits From

See Also

Standard Gestures

class NSClickGestureRecognizer

A discrete gesture recognizer that tracks a specified number of mouse clicks.

class NSPanGestureRecognizer

A continuous gesture recognizer for panning (dragging) gestures.

class NSRotationGestureRecognizer

A continuous gesture recognizer that tracks two trackpad touches moving opposite each other in a circular motion.

class NSMagnificationGestureRecognizer

A continuous gesture recognizer that tracks a pinch gesture used to magnify content.