Next: Plotting
Up: Mouse input
Previous: Bind
Contents
Index
Mouse variables
When mousing is active, clicking in the active window will set several user
variables that can be accessed from the gnuplot command line. The coordinates
of the mouse at the time of the click are stored in MOUSE_X MOUSE_Y MOUSE_X2
and MOUSE_Y2. The mouse button clicked, and any meta-keys active at that time,
are stored in MOUSE_BUTTON MOUSE_SHIFT MOUSE_ALT and MOUSE_CTRL. These
variables are set to undefined at the start of every plot, and only become
defined in the event of a mouse click in the active plot window. To determine
from a script if the mouse has been clicked in the active plot window, it is
sufficient to test for any one of these variables being defined.
plot 'something'
pause mouse
if (defined(MOUSE_BUTTON)) call 'something_else'; \
else print "No mouse click."
It is also possible to track keystrokes in the plot window using the mousing
code.
plot 'something'
pause mouse keypress
print "Keystroke ", MOUSE_KEY, " at ", MOUSE_X, " ", MOUSE_Y
When pause mouse keypress is terminated by a keypress, then MOUSE_KEY will
contain the ascii character value of the key that was pressed. MOUSE_CHAR will
contain the character itself as a string variable. If the pause command is
terminated abnormally (e.g. by ctrl-C or by externally closing the plot window)
then MOUSE_KEY will equal -1.
Note that after a zoom by mouse, you can read the new ranges as GPVAL_X_MIN,
GPVAL_X_MAX, GPVAL_Y_MIN, and GPVAL_Y_MAX, see gnuplot-defined variables (p. ).
Next: Plotting
Up: Mouse input
Previous: Bind
Contents
Index
Ethan Merritt
2007-03-03