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

NotebookEventActions

NotebookEventActions
is a notebook option that gives a list of actions to perform when specified events occur in connection with the notebook.
  • NotebookEventActions specifies that should be evaluated whenever 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 Mathematica would take for that event.
Set up a certain action to take place when a notebook is closed:
With the notebook open, is unchanged:
When you close the notebook window, is incremented:
Set up a certain action to take place when a notebook is closed:
In[1]:=
Click for copyable input
With the notebook open, is unchanged:
In[3]:=
Click for copyable input
Out[3]=
When you close the notebook window, is incremented:
In[4]:=
Click for copyable input
Out[4]=
Create a notebook window:
Set NotebookEventActions so that the notebook will change color when clicked:
Clicking the notebook changes its background:
Make an action occur when the Enter key is pressed:
Define actions for and :
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:
This NotebookEventActions setting blocks the normal Enter key behavior:
Pressing Enter changes the background but does not start a new line:
This inserts a newline as part of the action specified for :
Pressing Enter 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 Enter changes the background without entering a newline:
Also, NotebookEventActions has been reset to None:
Now, more Enter keystrokes add new lines as usual:
New in 6