How to judge NSEvent from trackpad click, not tap to click

前提是你 提交于 2021-01-27 13:00:42

问题


When "tap to click" checked, how judge NSEvent is from trackpad click(pressed down) or tap to click.

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

回答1:


To find out if someone only "tap to click" you could use

func pressureChange(with event: NSEvent) 

in your NSViewController on NSView.

If someone only "tap" the function will not be triggered. In case of a click you will get the pressure level on pressure change.

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


来源:https://stackoverflow.com/questions/53966067/how-to-judge-nsevent-from-trackpad-click-not-tap-to-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!