This function is useful in developing interactive graphics applications.
result = mouse(system, style, prompt)
result = [x_pressed, y_pressed, x_released, y_released,
xndc_pressed, yndc_pressed, xndc_released,
yndc_released, system, button, modifiers]
If system>=0, the first four coordinate values will be relative to that coordinate system. For
system<0, the first four coordinate values will be relative to the coordinate system under the mouse
when the button was pressed.
The second four coordinates are always normalized device coordinates, which start at (0, 0) in the lower left corner of the 8.5x11 sheet of paper the picture will be printed on, with 0.0013 NDC unit being 1/ 72.27 inch (1. 0 point). Look in the style sheet for the location of the viewport in NDC coordinates (see the style keyword).
If style is 0, there will be no visual cues that the mouse command has been called; this is intended for a simple click. If style is 1, a rubber band box will be drawn; if style is 2, a rubber band line will be drawn. These disappear when the button is released.
Clicking a second button before releasing the first cancels the mouse function, which will then return nil. Ordinary text input also cancels the mouse function, which again returns nil.
The left button reverses foreground for background (by XOR) in order to draw the rubber band (if any). The middle and right buttons use other masks, in case the rubber band is not visible with the left button.
result[8] is the coordinate system in which the first four coordinates are to be interpreted. result[9] is the button which was pressed, 1 for left, 2 for middle, and 3 for right (4 and 5 are also possible).
result[10] is a mask representing the modifier keys which were pressed during the operation: 1 for shift, 2 for shift lock, 4 for control, 8 for mod1 (alt or meta), 16 for mod2, 32 for mod3, 64 for mod4, and 128 for mod5.