PV-WAVE Foundation > User Guide > Displaying 2D Data > Getting Input from the Cursor
Getting Input from the Cursor
The CURSOR procedure reads the position of the graphics cursor of the current graphics device. It enables the graphic cursor on the device, optionally waits for the user to position it and press a mouse button to terminate the operation (or type a character if the device has no mouse), and then reports the cursor position.
The form of a CURSOR call, where x and y are output variables holding the cursor’s x and y position, and wait specifies when CURSOR returns, is:
CURSOR, x, y [, wait] 
For detailed information on the CURSOR procedure, its parameters and optional keywords, see the description in the PV‑WAVE Reference.
The following code draws lines between points marked with the left or middle mouse button. Press the right mouse button to exit the routine.
; Get the initial point in normalized coordinates.
CURSOR, X, Y, /Normal, /Down
; Repeat until the right button is pressed.
WHILE (!ERR NE 4) DO BEGIN
; Get the second point.
CURSOR, X1, Y1, /Normal, /Down
; Draw the line.
PLOTS, [X, X1], [Y, Y1], /Normal
; Make the current second point be the new first.
X = X1 & Y = Y1
ENDWHILE
For another example, the following simple procedure can be used to label plots using the cursor to position the text:
; Text is the string to be written on the screen.
PRO ANNOTATE, TEXT
; Ask the user to mark the position.
PRINT, 'Use the mouse to mark the text starting point:'
; Get the cursor position after any button press.
CURSOR, X, Y, /Normal, /Down
; Write text at specified position. Using NoClip ensures that
; text will appear even if it is outside of plotting region.
XYOUTS, X, Y, TEXT, /Normal, /NoClip
END
To place the annotation on a device with an interactive pointer, call this procedure with the command:
ANNOTATE, 'Text for label'
Then move the mouse to the desired spot and press the left button.