4

我必须按照代码mouseDown在我的自定义上捕获 sNSView但我认为这只会捕获多少次点击(使用clickCount),而不是使用多少个手指来点击:

- (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");
    }
}

关于如何在我的自定义 NSView 上用 3 个手指捕捉 1 个水龙头的任何想法?我想重现类似 Finder.app 选项的内容,您可以在其中用 3 根手指点击文件,然后会显示 QuickLook 面板。
谢谢!

4

2 回答 2

0

尝试在 mouseUp: 方法中执行此操作(而不是 mouseDown:)。此外,您不必设置跟踪区域来接收 mouseUp: 或 mouseDown: 事件。

于 2013-01-27T21:52:17.127 回答
-1

点击事件

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

“如果您在 NSView 中的点击速度足够快,您将从方法“[theEvent clickCount]”中获得事件“点击计数”。

尝试在 mouseDown 中记录点击次数

NSLog(@"%d",[事件点击次数]); 并尝试点击快一点。”

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

触摸事件

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

在 OS X >= 10.6 中,您可以尝试覆盖这些触摸事件手势

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

&

添加

[自我 setAcceptsTouchEvents:YES]; 在初始化

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

希望能帮助到你 !!!

于 2013-01-28T14:03:50.153 回答