gpt4 book ai didi

objective-c - 如何在自定义 NSView 上用 3 个手指(NSEvent)捕捉 1 次点击?

转载 作者:搜寻专家 更新时间:2023-10-30 19:50:10 24 4
gpt4 key购买 nike

我必须按照代码在我的自定义 NSView 上捕获 mouseDown,但我认为这只会捕获多少次点击(使用 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 面板。
谢谢!

最佳答案

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

关于objective-c - 如何在自定义 NSView 上用 3 个手指(NSEvent)捕捉 1 次点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14550669/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com