问题
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