Hi all,
My program involves users to make responses via keypresses and mouseclicks. The problem is if they use either repeatedly, then they receive a string of feedbacks, with only the first one being relevant. How do I ensure that the first mouse click is the only one registered (until I'm ready for the next mouseclick) and the same question for keypress. Script is below:
on keyDown theKey
put theKey into thisKey
if thisKey="d" or thisKey="k" then
on mouseUp pMouseBtnNum
if mouseClickOK then buzz
else exit mouseUp
end mouseUp
on mouseUp pMouseBtnNum
if mouseClickOK is false then exit mouseUP
put "Rect3" into clickedRect
foilClicked
end mouseUp
I could do it with a boolean I suppose, but I imagine there is a more elegant way.
Josh
Clearing a message buffer (mouse and keypress)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Hi Josh,
You could try using the 'flushEvents' function. To eat all the events that happened since your script started, use:
Hope this helped,
Jan Schenkel.
You could try using the 'flushEvents' function. To eat all the events that happened since your script started, use:
Code: Select all
on mouseUp
-- do my normal processing
...
-- setup for the next question
...
-- now eat all user events in the queue
get flushEvents("all")
end mouseUp
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Hi,
Flushevents won't do any good in this case. Using a variable with a boolean is the way to go.
Best,
Mark
Flushevents won't do any good in this case. Using a variable with a boolean is the way to go.
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