首页 > 解决方案 > 如何从触控板点击判断NSEvent,而不是点击点击

问题描述

当勾选“点击点击”时,如何判断 NSEvent 是来自触控板点击(按下)还是点击点击。

- (void)mouseEvent:(NSEvent*)theEvent {
  if ((type == NSLeftMouseUp || type == NSLeftMouseDown) && [theEvent subtype] == NSEventSubtypeTouch) {
    // How to detect touchpad is real pressed?? Not tap to cllick
  }
}

标签: objective-cmacoscocoacocoa-touchnsevent

解决方案


要了解是否有人只能“点击以单击”,您可以使用

func pressureChange(with event: NSEvent) 

在 NSView 上的 NSViewController 中。

如果有人只是“点击”该功能将不会被触发。如果单击,您将获得压力变化的压力水平。

   override func pressureChange(with event: NSEvent) {
        super.pressureChange(with: event)
        print("pressure \(event.pressure)")
    }

推荐阅读