MOUSEX
From QB64 Wiki
The _MOUSEX function returns the current horizontal(column) mouse cursor position when read after _MOUSEINPUT.
- column% = _MOUSEX
Usage:
- SCREEN 0 returns the SINGLE horizontal text column position. Graphic screens return the INTEGER pixel columns.
- To calculate text columns in graphic modes divide the return by 8 or the _PRINTWIDTH of one _FONT character.
- _MOUSEINPUT MUST be used to detect any changes in the mouse position and is required for any coordinate returns.
Example: 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:
- _MOUSEY, _MOUSEBUTTON, _MOUSEWHEEL
- _MOUSEINPUT, _MOUSEMOVE
- _MOUSESHOW, _MOUSEHIDE
- Controller_Devices