Gesture Recognizers

Gesture recognizers, which were added in OS X 10.10, provide a higher-level means of handling mouse input. If you have used UIKit’s gesture recognizers on iOS you will find them very familiar.

Each gesture recognizer is designed to recognize one specific gesture:

  • NSClickGestureRecognizer

  • NSPanGestureRecognizer

  • NSMagnificationGestureRecognizer

  • NSPressGestureRecognizer

  • NSRotationGestureRecognizer

Gesture recognizers are added to a specific view and report the gestures using target/action, just like controls:

 ​ ​ ​ ​f​u​n​c​ ​s​e​t​u​p​P​a​n​(​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​l​e​t​ ​p​a​n​ ​=​ ​N​S​P​a​n​G​e​s​t​u​r​e​R​e​c​o​g​n​i​z​e​r​(​t​a​r​g​e​t​:​ ​s​e​l​f​,​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.