User`s guide
Monitoring Events
The key to pointing-device-driven programming is an event loop. In an event loop, you wait
for an event (from the keyboard or pointer device) and when the correct event occurs in the
proper place, your program initiates some appropriate action. V+ can monitor many different
events including button up, button down, double click, open window, and menu select. The
example code in the following sections will use event 2, button up, and event 14, menu
select. For details on the different events that can be monitored, see the documentation for
the GETEVENT program instruction in the V+ Language Reference Guide.
The basic strategy for an event loop is:
1. Wait for an event to occur.
2. When an event is detected:
a. If it is the desired event, go to step 3
b. Otherwise, return to step 1.
3. Check the data from the event array (not necessary for event 14, menu select):
a. If it is appropriate, go to step 4.
b. Otherwise, return to step 1.
4. Initiate appropriate action.
5. Return to step 1.
GETEVENT Instruction
The instruction that initiates monitoring of pointer device and keyboard events is GETEVENT.
Its simplified syntax is:
GETEVENT (lun) event[]
lun Logical unit number of the window to be monitored.
event[] Array into which the results of the detected event are stored. The
value stored in event[0] indicates which event was detected.
If event[0] is 2, a button-up event was detected, in which case:
event[1] indicates the number of the button pressed. (For two-button
devices, 2 = left button, 4 = right button. For three-button
devices, 1 = left button, 2 = middle button, 4 = right button.)
event[2] is the X value of the pointer location of the click.
event[3] is the Y value of the pointer location of the click.
Monitoring Events
V+Language User's Guide, v17.0
Page 248










