Custom Button on touchscreen sometimes fires twice


I have Custom Canvas Button on Raspberry Pi Desktop App.
There is resistive touchscreen (it’s used outside) that user have to press harder than capasitive ones.
Problem is that sometimes when user touch button, action event fires twice.
What is the best way to prevent this?



I got that on a Desktop application/ PushButton: I add a Boolean (PushedBool) and check at click time: if False, I execute the code then set it to False.

My (supid) user stopped to execute two times the same action :wink:

Same thing can happen with a dirty mechanical switch attached to a GPIO on the Pi where it is called keybounce.
Add a property to your canvas button:

ignoreUntil As Double.
Then in the action event:

If Microseconds<ignoreUntil Then Return // ignore the push Else ignoreUntil = Microseconds + 500000 // ignore any more pushes from now for 1/2 second // do your action End If

Thanks for both!
My button opens modal window and i think this another action fires after first dialog closes.
So I made PushedBool and timer with 500milliseconds. When modal window closes timer makes PushedBool back to false with delay.


We often disable button directly in the action event, then start action and on the end may enable it again.