plevent

is the user's interrupt routine

parametertypeunitsdescription
xpointer,ypointerfloatuuposition of the mouse cursor at the moment of the interrupt
event_codeint--value of the code that caused the interrupt
returns:void

Description

plevent is the user's interrupt routine. The standard one, delivered with the SIMPLOT-package only shows the position of the mouse cursor, until the q-key is hit which then causes the application to exit. The user should use a copy of plevent and change it to his needs.

Possible values for event_code are the ASCII-values of keys and values predefined in simplot.h with self-explaining names:
ArrowDownF1MouseDrag
ArrowLeftF2MouseLeftDown
ArrowRightF3MouseLeftUp
ArrowUpF4MouseMiddleDown
DeleteF5MouseMiddleUp
EndF6MouseRightDown
EscapeF7MouseRightUp
HomeF8
InsertF9
PageDownF10
PageUpF11
F12
Except for MouseLeftUp, MouseMiddleUp and MouseRightUp, the values are positive and are generated by key/button press actions. Key/button releases generate the opposite values. One can thus discard key/button release actions by discarding negative event codes. Several event classes may be distinguished using plget:
  • plget(EVENT_ASCII) is non-zero if the event was caused by an ASCII key
  • plget(EVENT_BUTTON) is non-zero if the event was caused by a mouse button
  • plget(EVENT_DOWN) is non-zero if the event was caused by a key or button being pressed
  • plget(EVENT_FUNCTION) is non-zero if the event was caused by a function key
  • plget(EVENT_UP) is non-zero if the event was caused by a key of button release

Examples

Here is the simplest example, using the default versions of plevent and pldraw, It shows an X window with a 'Quit' button and, with one of the mouse buttons pressed, horizontal and vertical hairlines plus the
#include <simplot.h>
int main () {
   plinit(X,"",100,100,10,10,"","");
   plloop();
}
See plloop for a more complex example program using several event codes.

See also

plloop