Page 1 of 4
No way to prevent clicks on a button
Posted: Thu Jun 20, 2013 4:50 pm
by Mag
EDIT: I changed the topic title to reflect better the problem
When you need to do some long operations you need to prevent user to continue to click on buttons and start operations.
In this situation I tried to use a blended cover button to put over the card. Unfortunately you can continue to tap and have the script of the buttons activated, because I hide the cover button as soon as the operation is finished. My only solution is to wait some ticks before to hide the cover button?
PS
Also, what is the best way to trap also the taps when you are switching from a card to another? I see that you can tap and the object that receives it it's the one under the finger in the new card, which is not good

Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:05 pm
by Mag
PS
I also add these commands to the cover button, but the tap continues to go to the buttons below
on mouseUp
answer "mouseUp"
end mouseUp
on mouseDown
answer "mouseDown"
end mouseDown
on touchEnd
answer "touchEnd"
end touchEnd
on touchRelease
answer "touchRelease"
end touchRelease
on touchStart
answer "touchStart"
end touchStart
on touchMove
answer "touchStart"
end touchMove
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:06 pm
by Mark
Hi,
What exactly is the reason that you don't want the user to click the button again right after the script finishes?
I often see people disable a button while it is performing a task. One should not do this, because if something goes wrong in the script, the feature can't be accessed any more until the programme is restarted. Instead, you can check if the script is currently running:
Code: Select all
local lBusy
on mouseUp
if lBusy is true then
beep
answer warning "I'm busy. Do you want me to start again?" with "OK" or "Cancel"
if it is "Cancel" then
exit mouseUp
else
put false into lBusy
send "mouseUp" to me in 100 millisecs
end if
end if
put true into lBusy
repeat with x = 1 to 1000000 with messages
if lBusy is false then exit mouseUp
// do something here
wait 0 millisecs with messages
end repeat
put false into lBusy
end mouseUp
This is just an example. You'll have to adjust the script to your own needs.
Kind regards,
Mark
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:13 pm
by Mag
Hi Mark, thank you for the interesting code, I will study it!
I have two buttons, one of them goes to the next card and one start to record a video (with mergAV). I need to disable them because mergAV camCreate control need some time to create the control and I don't want people can click on the two buttons while the control is not ready.
I need this to avoid that an user see starting things without learning why (infact the user tap is queued and fire when the control is created some second after the tap)...
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:16 pm
by jmburnod
Hi Mark and Mag
cancel misses in the answer dialog
Code: Select all
answer warning "I'm busy. Do you want me to start again?" with "cancel" or "OK"
Kind regards
Jean-Marc
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:21 pm
by Mark
Jean-Marc,
Yeah, you're right. I'll edit the code. I think that "Cancel" should be the default.
Best,
Mark
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:28 pm
by Mag
So I have 6 buttons, I have to put in 6 buttons a check to know if the app is busy to do something else before to execute the scripts?
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 5:47 pm
by Mag
Disabling the buttons don't work because when I restore them, they intercept the event that is queued while the app was busy.
What I really need is to trap the user events like mouseDown while the creation of the native control is made.
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 6:50 pm
by Mark
Hi,
What about displaying a black screen on top of everything else with a white circular progress indicator until the recording video object appears?
Kind regards,
Mark
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 7:36 pm
by Mag
Hi Mark, seems interesting, do you mean to go to another stack until the work is finished?
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 10:46 pm
by Mark
Hi,
No, another stack makes things more complicated on iOS. Just show a group with a black rectangle as large as the card the progress indicator, covering everything else. Hide it when the recording control has appeared or when the user stops recording, whichever is easier or looks better.
Kind regards,
Mark
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 10:50 pm
by jmburnod
Yes, just a curtain
Re: Best way to prevent user clicking on a button
Posted: Thu Jun 20, 2013 10:58 pm
by Mark
Right.
Mark
Re: Best way to prevent user clicking on a button
Posted: Fri Jun 21, 2013 12:12 am
by Mag
Thanks, this is exactly what I'm searching to do. The problem is that the mouse event (e.g. mouseUp) is performed by LiveCode at the end of the creation of the control, not when it takes place. At that time there is not any curtain...
So I guess i have to find a way to learn when the control is ready and remove the curtain only some time after that. Currently the remove curtain statement is just after the create control one:
Code: Select all
show curtain
create control
hide curtain
Re: Best way to prevent user clicking on a button
Posted: Sun Jun 23, 2013 9:44 am
by Mag
SUMMARY
When LiveCode is engaged in an intensive task it collects user clicks and it delivers them to the targets when the task is ended.
So, in this situation, there is no way to prevent an user clicks on a button.