Bottlenecking of clicks due to the "wait" command

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ac11ca
Posts: 41
Joined: Sun Mar 16, 2008 2:22 am

Bottlenecking of clicks due to the "wait" command

Post by ac11ca » Thu Mar 20, 2008 6:01 am

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

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Keyboard buffer

Post by bjb007 » Thu Mar 20, 2008 7:38 am

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.
Life is just a bowl of cherries.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Mar 20, 2008 10:59 am

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:

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
Make sure that the cantAbout of your stack is true while you excute this script.

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

ac11ca
Posts: 41
Joined: Sun Mar 16, 2008 2:22 am

Post by ac11ca » Sun Mar 23, 2008 1:48 am

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.

Post Reply