My solution is to protect the mouseUp handler with a test for the mouseDown position. If the mouseDown position is 'nil', then the mouseUp will simply exit. The mouseDown position is of course initialised in mouseDown and removed in mouseUp.
Like this:
var mouseDownPosition: CGPoint?
override func mouseDown(theEvent: NSEvent) {
if mouseDownPosition != nil {
log.atLevelInfo(id: 0, source: "mouseDown", message: "Old mouseDownPosition still available, overwriting now")
}
mouseDownPosition = convertPoint(theEvent.locationInWindow, fromView: nil)
}
override func mouseUp(theEvent: NSEvent) {
if mouseDownPosition == nil {
log.atLevelDebug(id: 0, source: "mouseUp", message: "Exit, no mouseDownPosition available")
return
}
... Handle the mouseUp here
// The mouseDownPosition has been consumed, remove it
mouseDownPosition = nil
}
Happy coding...
Did this help?, then please help out a small independent.
If you decide that you want to make a small donation, you can do so by clicking this
link: a cup of coffee ($2) or use the popup on the right hand side for different amounts.
Payments will be processed by PayPal, receiver will be sales at balancingrock dot nl
Bitcoins will be gladly accepted at: 1GacSREBxPy1yskLMc9de2nofNv2SNdwqH
We don't get the world we wish for... we get the world we pay for.
Did this help?, then please help out a small independent.
If you decide that you want to make a small donation, you can do so by clicking this
link: a cup of coffee ($2) or use the popup on the right hand side for different amounts.
Payments will be processed by PayPal, receiver will be sales at balancingrock dot nl
Bitcoins will be gladly accepted at: 1GacSREBxPy1yskLMc9de2nofNv2SNdwqH
We don't get the world we wish for... we get the world we pay for.
I am looking for the website where I can play mouse tap counter and can check my tap speed. Let me know if you can suggest me some websites.
ReplyDelete