O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​,​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required