On Mac OS X, doing a 3-finger tap on a word pops up a window with a definition of the word.
Reacting on a triple tap in a NSTextView can most easily be done by overriding quickLookWithEvent:.
-(void)quickLookWithEvent:(NSEvent *)event
{
NSLog(@"Look at me! %@", event);
}
It also taught me that you can triple tap anything to invoke Quick Look on it.
Subclass NSTextView and override mouse down event (this is where the view usually handle the click/tap events):
-(void)mouseDown:(NSEvent*)event
{
if (event.clickCount == 3)
{
//Do your thing
}
}
Hope this helps.
If the triple click does not work for you (I am not currently in from of my mac to check), you could try something else. I know it works in iOS, I don't know about the trackpad gestures.
You could try adding a UITapGestureRecognizer to your view:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
tapGesture.numberOfTouchesRequired = 3;
//....
-(void)viewTapped:(UITapGestureRecognizer*)tap
{
if(tap.state == UIGestureRecognizerStateRecognized)
{
//you detected a three finger tap, do work
}
}
LATER EDIT:
I found this article in the apple documentation. Based on a sample from this article, here is some code which should be useful (from listing 8-5):
- (void)touchesBeganWithEvent:(NSEvent *)event {
if (!self.isEnabled) return;
NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseTouching inView:self.view];
if (touches.count == 3)
{
//Three finger touch detected
}
[super touchesBeganWithEvent:event];
}