This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

EventHandler

EventHandler
displays as expr, evaluating whenever occurs in connection with expr.
  • 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 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"Return or Enter key depressed
"EscapeKeyDown"Esc 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 , the values they give are those associated with the event that triggered that .
  • 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:
PassEventsDownAutomaticwhether to pass events to inner event handlers
PassEventsUpTruewhether to pass events to outer event handlers
Create text that turns red when clicked:
Create text that toggles between red and green when clicked repeatedly:
Create text that turns red when clicked:
In[1]:=
Click for copyable input
Out[1]=
 
Create text that toggles between red and green when clicked repeatedly:
In[1]:=
Click for copyable input
Out[1]=
Create a graphic that changes color when clicked:
Allow events to pass down to inner event handlers, changing the color as well as position:
Do not pass mouse events to the inner event handler:
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 Shift key is pressed:
Automatically fit a line to a set of points:
Piecewise interpolation through a set of points:
New in 6