MOUSE statement

Purpose

Turn on/off mouse event trapping and define which mouse events are to be trapped in the console input buffer.

Syntax

MOUSE {ON | OFF}

MOUSE buttons [,DOUBLE] [,MOVE] [,DOWN] [,UP]

Remarks

MOUSE ON turns on mouse event trapping and the mouse cursor.  MOUSE OFF turns off mouse event trapping and the mouse cursor.

buttons is a numeric  expression which defines one or more buttons to report:

Buttons

Definition

0

No button

1

Left

2

Right

4

Second left button

8

Third left button

16

Fourth left button

DOUBLE is an optional parameter that defines trapping for double-click events.  MOVE is an optional parameter and defines trapping for mouse movements.  DOWN is an optional parameter and defines trapping for mouse button clicks.  UP is an optional parameter and defines trapping for mouse button releases.

To trap for double and single clicks for up to 3 buttons on a mouse use:

MOUSE 7, DOUBLE, DOWN

All events are returned by the INKEY$ and WAITKEY$ functions.  Due to limitations imposed by the Microsoft Windows operating system, it is not possible to trap the mouse wheel events in a console application.

See also

INKEY$, MOUSEBUTTONS, MOUSESTAT, MOUSEX, MOUSEY, WAITKEY$

Example

MOUSE 3, DOUBLE, DOWN

MOUSE ON

 

DO

  i$ = WAITKEY$

  SELECT CASE LEN(i$)

    CASE 1

      PRINT i$;" key pressed"

    CASE 2

      PRINT "Alt+key pressed"

    CASE 4

      SELECT CASE ASC(i$, 3)

        CASE 2

          PRINT "Double-click";

        CASE 4

          PRINT "Single-click";

      END SELECT

      PRINT " at"; MOUSEY;",";MOUSEX

  END SELECT

LOOP UNTIL I$ = CHR$(27)  'ESC key