flushEvents

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
flushEvents(<eventType>)
Summary

Clears pending events from the event queue so they will not trigger handlers.

Introduced1.0
OSmac, windows, linux
Platformsdesktop, server
Parameters
NameTypeDescription
eventType"all": ignore all waiting events
"mouseDown": ignore mouse presses
"mouseUp": ignore mouse releases
"keyDown": ignore keypresses
"keyUp": ignore key releases
"autoKey": ignore key repeats
"disk": ignore disk-related events
"activate": ignore windows being brought to the front
"highLevel": ignore Apple Events (on Mac OS and OS X systems)
"system": ignore operating system events
Example
put flushEvents("activate") into trashVar
get flushEvents("all")
Values
NameTypeDescription
return

The flushEvents function always returns empty.

RelatedMessage: suspendStack, appleEvent, mouseUp, mouseDown, resumeStack
Command: cancel
Glossary: LiveCode, event, return, handler, mouse button, trigger, execute, message, application, object
Control Structure: function
Description

Use the flushEvents function to prevent unwanted messages from being sent during a handler's execution.

Typically, you use the flushEvents function in a handler to dump user actions that have occurred during the handler. For example, if a button has a mouseUp handler that takes a few seconds to run, the user might click again during that time. To prevent those extra clicks from causing the handler to run again, use the flushEvents function :

on mouseUp
-- ...lengthy handler goes here...
-- get rid of clicks since the handler started:
put flushEvents("mouseUp") into temp

end mouseUp

To clear multiple event types, call the flushEvents function once for each event type you want to clear.

Although some of the eventTypes have the same names as built-in LiveCode messages, there is a distinction. For example, the mouseDown event type is the operating system's response to the user clicking the mouse button. When the operating system sends this event to the application, LiveCode sends a mouseDown message to the target object. The expression flushEvents(mouseDown) prevents the application from responding to any mouseDown events it has received from the operating system, but has not yet processed.

Tagsui