I want to detect scroll gestures (two fingers on trackpad). How should i do that?
Looks like you want to override your view's scrollWheel:
method. You can use the NSEvent
's deltaX
and deltaY
methods to get how much the user has scrolled by.
Code:
@implementation MyView
- (void)scrollWheel:(NSEvent *)theEvent {
NSLog(@"user scrolled %f horizontally and %f vertically", [theEvent deltaX], [theEvent deltaY]);
}
@end
You also may want to take a look at the Handling Trackpad Events Guide. This will show you how to capture custom gestures, in addition to standard ones.