objective-cmacoscocoatrackpad

OS X Cocoa - how can one detect trackpad zoom gestures?


How can one detect two finger zoom gestures on MacBook trackpad? (within a selected NSView)


Solution

  • There's an event type (NSEventTypeMagnify) for pinch gestures, as well as a NSResponder method (-magnifyWithEvent:) for handling such events. Cocoa differs a bit from Cocoa Touch in this respect; on the desktop, you generally let the OS interpret the gestures for you, and you respond to the meaning of the gesture rather than trying to identify the gesture itself.