Debounce screen Click?

enonod

Well-Known Member
Licensed User
Longtime User
I am having trouble with Click events in that as I remove the finger or stylus I get double or more events, probably imperceptible finger bounce.
Is there any code already available to prevent this please?
 

Cableguy

Expert
Licensed User
Longtime User
set a global variable to hold a tipestamp, on the buttons click event, compare the existing timestamp with the timestamp at wich the event was fired, if the diference is lesser than x milisecs then ignore it and save the new timestamp.
This in a nutshell...do some digging and experimenting
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
My 2 cents to this topic

B4X:
Sub Process_Globals
    Dim LastClick As Double
End Sub

Sub Button2_Click
    If DateTime.Now- LastClick < 1000 Then Return

'// your code here
LastClick = DateTime.Now
end sub
 
Last edited:
Upvote 0
Top