1# Demonstrate screen interaction using mouse variables
2#
3#     MOUSE_X MOUSE_Y MOUSE_KEY MOUSE_CHAR
4#
5# On entry, LID is the identifier for the previous label
6#
7#
8# Loop until we see an <esc>
9#
10while (1) {
11
12    if (exists("MOUSE_KEY") && MOUSE_KEY == 27) {
13	break
14    }
15
16    LID = LID + 1
17    set label 2 sprintf(">>> READY FOR LABEL %d <<<",LID-100)
18    set label 2 at graph .02, graph .65 tc lt (LID-100)
19    replot
20
21    #
22    # Get mouse position and first character of label
23    #
24    pause mouse key
25
26    if (MOUSE_KEY == 27) {
27	break
28    }
29
30    LABEL = ""
31    LABEL_X = MOUSE_X
32    LABEL_Y = MOUSE_Y
33    set label LID LABEL at LABEL_X, LABEL_Y
34    replot
35    #
36    # Call routine that catches keystrokes one by one and
37    # updates the label
38    #
39    load "mouselab_2.dem"
40    #
41    # Print out final label details
42    #
43    show label LID
44
45} # end of loop waiting for <esc>
46