QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _MOUSEX function returns the current horizontal (column) mouse cursor position when read after _MOUSEINPUT.

Syntax

pixelColumn% = _MOUSEX

Description

QBasic

Example(s)

A simple mouse drawing board using _MOUSEX and _MOUSEY coordinate values.


SCREEN 12
LINE (99, 9)-(601, 401), 7, BF
LINE (101, 11)-(599, 399), 8, BF
tm$ = " Column = ###  Row = ###  Button1 = ##  Button2 = ##  Button3 = ##"
LOCATE 29, 20: PRINT "LeftButton = draw - RightButton = Erase";
DO: K$ = INKEY$
  DO WHILE _MOUSEINPUT
    X = _MOUSEX: Y = _MOUSEY
    IF X > 100 AND X < 600 AND PX > 100 AND PX < 600 THEN
      IF Y > 10 AND Y < 400 AND PY > 10 AND PY < 400 THEN
        IF _MOUSEBUTTON(1) THEN LINE (PX, PY)-(X, Y), 15
        IF _MOUSEBUTTON(2) THEN LINE (101, 11)-(599, 399), 8, BF
      END IF
    END IF
    PX = X: PY = Y
    LOCATE 28, 10: PRINT USING tm$; X; Y; _MOUSEBUTTON(1); _MOUSEBUTTON(2); _MOUSEBUTTON(3)
  LOOP
LOOP UNTIL K$ = CHR$(27)
SYSTEM 

See Also