4

I have to following code to catch mouseDowns on my custom NSView but I think this only catches how many taps (using the clickCount), not how many fingers were used to tap:

- (void)updateTrackingAreas{
    if(trackingArea != nil) {
        [self removeTrackingArea:trackingArea];
    }
    int opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways);
    trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
                                                 options:opts
                                                   owner:self
                                                userInfo:nil];
    [self addTrackingArea:trackingArea];
}

- (void)mouseDown:(NSEvent *)theEvent{
    NSLog(@"%li",theEvent.clickCount);
    if ([theEvent clickCount] == 3){
        NSLog(@"3");
    }else{
        NSLog(@"normal");
    }
}

Any ideas on how to catch 1 tap with 3 fingers on my custom NSView? I'd like to reproduce something like the Finder.app option, where you tap with 3 fingers on a file and a QuickLook panel shows up.
Thanks!

Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76

2 Answers2

0

Try doing this in the mouseUp: method (instead of mouseDown:). Also, you don't have to set up a tracking area to receive mouseUp: or mouseDown: events.

Joel
  • 44
  • 3
-1

Click Events

////////////////////

"You will get the event "click count" from the method "[theEvent clickCount]", if you are clicking fast enough in NSView.

Try logging the click count in mouseDown

NSLog(@"%d",[theEvent clickCount]); & try clicking little faster."

///////////////////

Touch Events

//////////////////

In OS X >= 10.6, you can try overriding these touch event gestures

  • (void)touchesBeganWithEvent:(NSEvent *)event;
  • (void)touchesMovedWithEvent:(NSEvent *)event;
  • (void)touchesEndedWithEvent:(NSEvent *)event;
  • (void)touchesCancelledWithEvent:(NSEvent *)event;

&

add

[self setAcceptsTouchEvents:YES]; in init

/////////////////

Hope it Helps !!!

arun.s
  • 1,528
  • 9
  • 12