I want to detect scroll gestures (two fingers on trackpad). How should i do that?
You should do that by implementing touch event methods of NSView
in your custom subclass.
These methods are :
- (void)touchesBeganWithEvent:(NSEvent *)event;
- (void)touchesMovedWithEvent:(NSEvent *)event;
- (void)touchesEndedWithEvent:(NSEvent *)event;
- (void)touchesCancelledWithEvent:(NSEvent *)event;
The NSEvent
object coming along as a paramter contains informations about the touches involded. In particular, you may retrieve them using :
-(NSSet *)touchesMatchingPhase:(NSTouchPhase)phase inView:(NSView *)view;
Also, in the custom view subclass, you must first set it like this :
[self setAcceptsTouchEvents:YES];
in order to recieve such events.