Skip to content

Instantly share code, notes, and snippets.

@eonist
Created July 26, 2017 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eonist/fa2558a1b0c63aa80b6e62d960628805 to your computer and use it in GitHub Desktop.
Save eonist/fa2558a1b0c63aa80b6e62d960628805 to your computer and use it in GitHub Desktop.
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