MOUSEX: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
m (Removed protection from "MOUSEX") |
No edit summary |
||
Line 15: | Line 15: | ||
==QBasic/QuickBASIC== | ==QBasic/QuickBASIC== | ||
* In [[SCREEN]] 0, QBasic's [[CALL ABSOLUTE|ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. | * In [[SCREEN]] 0, QBasic's [[CALL ABSOLUTE|ABSOLUTE]] returned graphic coordinates. QB64 mouse functions return the text coordinates. | ||
{{PageExamples}} | {{PageExamples}} | ||
''Example:'' A simple mouse drawing board using [[_MOUSEX]] and [[_MOUSEY]] coordinate values. | ''Example:'' A simple mouse drawing board using [[_MOUSEX]] and [[_MOUSEY]] coordinate values. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|SCREEN (statement)|SCREEN}} 12 | {{Cl|SCREEN (statement)|SCREEN}} 12 | ||
{{Cl|LINE}} (99, 9)-(601, 401), 7, BF | {{Cl|LINE}} (99, 9)-(601, 401), 7, BF | ||
Line 39: | Line 39: | ||
{{Cl|LOOP}} | {{Cl|LOOP}} | ||
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) | {{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27) | ||
{{Cl|SYSTEM}} | {{Cl|SYSTEM}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Line 48: | Line 48: | ||
* [[_MOUSEINPUT]], [[_MOUSEMOVE]] | * [[_MOUSEINPUT]], [[_MOUSEMOVE]] | ||
* [[_MOUSESHOW]], [[_MOUSEHIDE]] | * [[_MOUSESHOW]], [[_MOUSEHIDE]] | ||
* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}} | * [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}} | ||
* [[Controller Devices]] | * [[Controller Devices]] | ||
{{PageNavigation}} | {{PageNavigation}} |
Revision as of 02:08, 23 January 2023
The _MOUSEX function returns the current horizontal (column) mouse cursor position when read after _MOUSEINPUT.
Syntax
- pixelColumn% = _MOUSEX
Description
- SCREEN 0 returns the INTEGER horizontal text column position (from build 20170817/62 onward); older versions return a SINGLE horizontal text column position. Use INTEGER variables to avoid floating decimal returns.
- Graphic screen modes 1, 2 and 7 to 13 and _NEWIMAGE 32 bit return the INTEGER pixel columns.
- To calculate text columns in graphic modes, divide the return by 8 or the _FONTWIDTH of _FONT characters.
- _MOUSEINPUT must be used to detect any changes in the mouse position and is required for any coordinate returns.
QBasic/QuickBASIC
- In SCREEN 0, QBasic's ABSOLUTE returned graphic coordinates. QB64 mouse functions return the text coordinates.
Examples
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
- _MOUSEMOVEMENTX, _MOUSEMOVEMENTY (relative pointer moves)
- Controller Devices