Last active
February 15, 2018 14:32
-
-
Save eonist/35992a29d07e0f58c0acc8be93950533 to your computer and use it in GitHub Desktop.
ForceTouch handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var prevStage = 0 | |
override func pressureChange(with event: NSEvent) { | |
let curStage:Int = event.stage | |
if event.pressureBehavior == NSPressureBehavior.primaryDeepClick,prevStage != curStage { | |
switch (curStage,prevStage){ | |
case (0,1): | |
Swift.print("from idle to clickStage") | |
case (1,0): | |
Swift.print("from clickStage to idle") | |
case (1,2): | |
Swift.print("from clickStage to deepClickStage") | |
case (2,1): | |
Swift.print("from deepStage to clickStage") | |
default: break;//isn't possible | |
} | |
Swift.print("stageChange") | |
prevStage = curStage/*always set prevStage to curStage on stage change*/ | |
} | |
Swift.print("pressureChange") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment