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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.