MOUSE

MOUSE

Top  Previous  Next

 

The MOUSE statement enables or disables mouse input.

 

 

Format

 

MOUSE ON {SETTING var}

MOUSE OFF {SETTING var}

MOUSE expr {SETTING var}

 

where

 

expris an expression that evaluates to True or False.

 

varis the variable to receive the previous mouse state.

 

 

Mouse input is initially off.  Use of MOUSE ON enables mouse input until a subsequent MOUSE OFF statement.

 

The MOUSE expr format of this statement is equivalent to MOUSE ON if the value of expr is non-zero and MOUSE OFF if expr is zero or null.

 

The optional SETTING clause saves the previous mouse state in var which can be used later to revert to that state. Alternatively, the previous state can be obtained using the STATUS() function immediately after the MOUSE statement. In either case, the value is 1 if the mouse was enabled or 0 if it was disabled.

 

Mouse input is only available on console sessions, via QMTerm, and using AccuTerm with terminal types that have the -at suffix.  When the mouse is enabled, clicking a mouse button sends a message that can be retrieved via the normal keyboard input statements and functions. This message is prefixed by char(200) on non-ECS systems, character echar(0xF8C8) on ECS mode systems. The format of the qualifying data in the message varies between terminal types. Use of the KEYCODE() or KEYCODEV() function traps the mouse event prefix processes the qualifying data, leaving the button number in @MBUTTON and the screen position at which the mouse was clicked in @MCOL and @MROW.

 

The button state is the result of adding the values of each button that is depressed: 1 for the left button, 2 for the right button, 4 for the centre button. The x and y positions are based on character coordinates using the same conventions as for the cursor movement functions. Some terminal types only allow use of the left button.

 

 

Example

 

MOUSE ON

...

IF KEYCODEV() = KV$MOUSE THEN

  DISPLAY 'Mouse clicked at column ' : @MCOL : ', row ' : @MROW

END

 

This program fragment read mouse input, displaying the screen position.