NotebookEventActions
is a notebook option that gives a list of actions to perform when specified events occur in connection with the notebook.
Details
- NotebookEventActions->{"event1":>action1,"event2":>action2,…} specifies that actioni should be evaluated whenever "eventi" occurs in connection with the notebook.
- The possible event specifications are the same as for EventHandler, with the following addition:
-
"WindowClose" window being closed - Settings for NotebookEventActions are often defined at the level of stylesheets, rather than for individual notebooks.
- By default, any action specified for an event by NotebookEventActions will override any default action that the Wolfram System would take for that event.
- The default behavior can be changed by including rules for PassEventsDown or PassEventsUp in the list given as the setting for NotebookEventActions.
Examples
open allclose allBasic Examples (1)
Scope (3)
Set NotebookEventActions so that the notebook will change color when clicked:
Clicking the notebook changes its background:
Make an action occur when the key is pressed:
Define actions for "MouseDown" and "MouseUp":
The background will be pink only while the mouse button is held down:
After the mouse is released, the notebook is back to its normal background:
Possible Issues (3)
This NotebookEventActions setting blocks the normal key behavior:
Pressing changes the background but does not start a new line:
This inserts a newline as part of the action specified for "ReturnKeyDown":
Pressing in this notebook inserts a newline as well as setting the background:
Specify a NotebookEventActions setting that goes away after being activated once:
A single changes the background without entering a newline:
Also, NotebookEventActions has been reset to None:
Text
Wolfram Research (2007), NotebookEventActions, Wolfram Language function, https://reference.wolfram.com/language/ref/NotebookEventActions.html.
CMS
Wolfram Language. 2007. "NotebookEventActions." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NotebookEventActions.html.
APA
Wolfram Language. (2007). NotebookEventActions. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NotebookEventActions.html