Clearing a message buffer (mouse and keypress)

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
Josh
Posts: 46
Joined: Sat Jan 12, 2008 6:42 am

Clearing a message buffer (mouse and keypress)

Post by Josh » Tue Apr 22, 2008 5:42 pm

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Apr 22, 2008 5:49 pm

Hi Josh,

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
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

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

Post by Mark » Wed Apr 23, 2008 8:31 am

Hi,

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

Post Reply