EventHandler
EventHandler[expr,{"event1":>action1,"event2":>action2,…}]
displays as expr, evaluating actioni whenever "eventi" occurs in connection with expr.
Details and Options
- Standard mouse-related event specifications include:
-
"MouseClicked" mouse clicked without moving {"MouseClicked",i} mouse button i clicked without moving "MouseDown" primary mouse button depressed {"MouseDown",i} mouse button i depressed "MouseDragged" mouse moving with primary button depressed {"MouseDragged",i} mouse moving with button i depressed "MouseMoved" mouse moves in the region defined by expr "MouseUp" primary mouse button released {"MouseUp",i} mouse button i released - For mouse events, EventHandler[expr, …] handles events for which the mouse is within the rectangular region defined by the display of expr.
- Standard keyboard-related event specifications include:
-
"KeyDown" any key on the keyboard depressed {"KeyDown","x"} key x depressed "ReturnKeyDown" or key depressed "EscapeKeyDown" key depressed "LeftArrowKeyDown" left arrow key depressed "RightArrowKeyDown" right arrow key depressed "UpArrowKeyDown" up arrow key depressed "DownArrowKeyDown" down arrow key depressed - Standard interface events include:
-
{"MenuCommand","name"} menu command with specified name chosen "WindowClose" closing of window requested - If functions like MousePosition or CurrentValue are evaluated in a particular actioni, the values they give are those associated with the event that triggered that actioni.
- When EventHandler expressions are nested, events are by default shared by all the expressions, with the innermost expression operating first on a particular event.
- The following options can be given:
-
Method "Preemptive" the evaluation method to use PassEventsDown Automatic whether to pass events to inner event handlers PassEventsUp True whether to pass events to outer event handlers - Typical possible settings for the Method option include "Preemptive" and "Queued".
- With the default setting PassEventsDown->Automatic, events handled by an EventHandler are not also passed to built-in event handlers in the Wolfram System front end.
Examples
open allclose allBasic Examples (3)
Scope (1)
Options (5)
Method (1)
By default, event handlers are evaluated on a preemptive link and time out after 5 seconds:
Use Method->"Queued" to evaluate button functions on the main link, which never times out:
PassEventsDown (2)
PassEventsUp (2)
By default, nested EventHandler actions are triggered upon the specified action:
By disabling PassEventsUp, prevent the outer EventHandler action from being triggered:
Allow the outer EventHandler action when the key is pressed:
Applications (2)
Properties & Relations (1)
EventHandler can be used with MousePosition:
Text
Wolfram Research (2007), EventHandler, Wolfram Language function, https://reference.wolfram.com/language/ref/EventHandler.html (updated 2008).
CMS
Wolfram Language. 2007. "EventHandler." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2008. https://reference.wolfram.com/language/ref/EventHandler.html.
APA
Wolfram Language. (2007). EventHandler. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EventHandler.html