Hi there, I have a problem that has to do with using the "wait" and possibly "disable" functions on a button. What I want to happen is the following:
User clicks on a button initially labeled "A" which, when pressed, changes in backgroundcolor for a second while displaying a certain number (coming from a variable called Risk here). After a second of displaying the number+color I want the button color to go back to normal grey and then the button to be unclickable for a second. After this the button should be re-enabled with the number again replaced by the letter A. This whole process is just so people notice that discrete trials are occurs, since on some occassions the same number will be prodcued, e.g., 3 3 3 3 and I want users to know that the number is actually being re-calculated each time they click, it just happens to be the same as before.
The code I have used is:
on mouseDown
add 1 to ButtonCnt
set the label of me to item 1 of line ButtonCnt of Risk
set the backgroundcolor of me to "117,170,249"
wait 1 seconds
set the backgroundcolor of me to "228,228,228"
end mouseDown
on mouseUp
disable me
wait for 1 seconds
set the label of me to A
enable me
end mouseUp
This seems to do the job, up until users start madly clicking during the "wait" and "disabled" times. These clicks are all recorded by the program and build up and sort of go crazy...
Is there some way to disable the registering of mouse clicks during the time between the initial click and the time the button become re-enabled?
Thanks for any help,
Adrian
Bottlenecking of clicks due to the "wait" command
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Keyboard buffer
This is just a clue, perhaps, but back in
the days of DOS there was a function to
clear the keyboard buffer so that extra
clicks weren't sent to a prog.
Perhaps someone more up-to-date on
this than I am will come to the rescue.
the days of DOS there was a function to
clear the keyboard buffer so that extra
clicks weren't sent to a prog.
Perhaps someone more up-to-date on
this than I am will come to the rescue.
Life is just a bowl of cherries.
Hi Adrian,
Why do you want this? Normally, if a user sees a number change, or a colour in this case, s/he's understand that the click has had its effect and there's no need for another click. If the user clicks anyway, there's nothing you can do about it. So, changing colour should be sufficient and there shouldn't be a reason to disable the button --even less to disable it for only second.
The problem here is, you're waiting with the button enabled, which means that any mouseClicks during that time are handled.
If you want it anyway, this might help:
Make sure that the cantAbout of your stack is true while you excute this script.
Best,
Mark
Why do you want this? Normally, if a user sees a number change, or a colour in this case, s/he's understand that the click has had its effect and there's no need for another click. If the user clicks anyway, there's nothing you can do about it. So, changing colour should be sufficient and there shouldn't be a reason to disable the button --even less to disable it for only second.
The problem here is, you're waiting with the button enabled, which means that any mouseClicks during that time are handled.
If you want it anyway, this might help:
Code: Select all
on mouseDown
if the backColor of me is "117,170,249" then
beep
else
add 1 to ButtonCnt
set the label of me to item 1 of line ButtonCnt of Risk
set the backgroundcolor of me to "117,170,249"
wait 1 sec with messages
set the backgroundcolor of me to "228,228,228"
end if
end mouseDown
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark,
I wanted this piece of coding because many of my users will be largely unmotivated and will likely try to 'click through' to the end of the sequence without paying much attention to the text coming up on the buttons.
I appreciate the coding you gave me, it seems to have done the trick and works quite well. The annoying beep sound is definately aversive enough to get users to slow down, I think
Cheers,
Adrian.
I wanted this piece of coding because many of my users will be largely unmotivated and will likely try to 'click through' to the end of the sequence without paying much attention to the text coming up on the buttons.
I appreciate the coding you gave me, it seems to have done the trick and works quite well. The annoying beep sound is definately aversive enough to get users to slow down, I think

Cheers,
Adrian.