I had issues when i did an animation like clicking on a button and shrink it that if you click twice on it it will perform 2 times or more the animation you want to do or if you start a task that can take some milliseconds like scrolling a panel from outside the screen to a specific position you really want to prevent the user to click on anything before you finished your task. this could lead to bugs in your app.
so until now what I did is I used a Boolean to check if the animation or that task has finished and then allowed the click event something like:
(click on the button to scroll the panel to be visible)
so first I set a boolean in globals
then I set it to TRUE before the animation. Now on each relevant button I check that boolean status like
and after the animation has finished I set it back to FALSE.
Now that's really a PITA and you will find yourself adding lots of checks to avoid accidental clicks.
so a MUCH simpler way to solve that issue is adding a panel for x ms and remove it after that to catch all your accidental clicks. it is much simpler to call that function and can be used in all b4x ide's
in b4a it could look like this:
and you can call it like this:
you could use #if B4A ... #if B4I... and make a code module for all ide's
if you have a better idea of how to prevent users to click anything while an animation is running for a specific time post your idea (code) here.
regards, ilan
so until now what I did is I used a Boolean to check if the animation or that task has finished and then allowed the click event something like:
(click on the button to scroll the panel to be visible)
so first I set a boolean in globals
B4X:
dim animStart as Boolean
then I set it to TRUE before the animation. Now on each relevant button I check that boolean status like
B4X:
if NOT(animStart) then ...
and after the animation has finished I set it back to FALSE.
Now that's really a PITA and you will find yourself adding lots of checks to avoid accidental clicks.
so a MUCH simpler way to solve that issue is adding a panel for x ms and remove it after that to catch all your accidental clicks. it is much simpler to call that function and can be used in all b4x ide's
in b4a it could look like this:
B4X:
Sub freeze(Time As Int)
Dim pnl As Panel
pnl.Initialize("freezepnl")
pnl.Color = Colors.Transparent
pnl.BringToFront
pnl.Elevation = 10dip
Activity.AddView(pnl,0,0,100%x,100%y)
Sleep(Time)
pnl.RemoveView
End Sub
Sub freezepnl_Touch (Action As Int, X As Float, Y As Float)
'do nothing
End Sub
and you can call it like this:
B4X:
Sub btn_Click
myPanel.Left = 120%x
myPanel.Visible = True
myPanel.BringToFront
myPanel.SetLayoutAnimated(500,0,0,myPanel.Width,myPanel.Height)
freeze(500) '<----- we dont let any clicks on our activity for 500 ms the same time we use for our animation
End Sub
you could use #if B4A ... #if B4I... and make a code module for all ide's
if you have a better idea of how to prevent users to click anything while an animation is running for a specific time post your idea (code) here.
regards, ilan