like pass, but without ending the handler

J. Landman Gay jacque at hyperactivesw.com
Thu Mar 1 13:20:38 EST 2007


Marielle Lange wrote:

> I discussed flushevents very brielfy with Marcus (van Houdt). The 
> recommendation was to stay away from using flushevents unless having a 
> very good reason to use it.
> 
> I am a psycholinguist, I am a lot more comfortable with regular 
> expressions than with lockmessages or flushevents constructs ;-). I 
> would be interested in hearing about some recipes. When to consider 
> using them? What to be careful about? (like the increase in CPU that was 
> mentioned when attempts of multithreading are made).

The reason to avoid them is because indiscriminate use can disrupt the 
message queue, as you might remove messages that your scripts expect to 
recieve.

I've found that flushEvents is hardly ever needed. It is usually 
sufficient to put a blocking handler in place so that the message stops 
as soon as it is sent. The most common usage for flushEvents is in 
software intended for young children or computer novices, where repeated 
mouse clicking is common. I have used flushEvents in software for 
special needs children who tend to click repeatedly on a button. These 
repeated clicks will accumulate and the button script will be executed 
many times. To prevent that, I cleared the queue of mouse events so that 
only the first click was executed.

Note that there is an old HyperCard trick that works in a similar way if 
all you need to clear are mouse messages:

   wait while the mouseclick


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list