1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 10:30:36 +00:00
QB64-PE/internal/help/_MOUSEX.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

56 lines
2.4 KiB
Plaintext

{{DISPLAYTITLE:_MOUSEX}}
The [[_MOUSEX]] function returns the current horizontal (column) mouse cursor position when read after [[_MOUSEINPUT]].
{{PageSyntax}}
: {{Parameter|pixelColumn%}} = [[_MOUSEX]]
{{PageDescription}}
* [[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.
{{PageExamples}}
''Example:'' A simple mouse drawing board using [[_MOUSEX]] and [[_MOUSEY]] coordinate values.
{{CodeStart}} '' ''
{{Cl|SCREEN (statement)|SCREEN}} 12
{{Cl|LINE}} (99, 9)-(601, 401), 7, BF
{{Cl|LINE}} (101, 11)-(599, 399), 8, BF
tm$ = " Column = ### Row = ### Button1 = ## Button2 = ## Button3 = ##"
{{Cl|LOCATE}} 29, 20: {{Cl|PRINT}} "LeftButton = draw - RightButton = Erase";
{{Cl|DO}}: K$ = {{Cl|INKEY$}}
{{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
X = {{Cl|_MOUSEX}}: Y = {{Cl|_MOUSEY}}
{{Cl|IF}} X > 100 {{Cl|AND (boolean)|AND}} X < 600 {{Cl|AND (boolean)|AND}} PX > 100 {{Cl|AND (boolean)|AND}} PX < 600 {{Cl|THEN}}
{{Cl|IF}} Y > 10 {{Cl|AND (boolean)|AND}} Y < 400 {{Cl|AND (boolean)|AND}} PY > 10 {{Cl|AND (boolean)|AND}} PY < 400 {{Cl|THEN}}
{{Cl|IF}} {{Cl|_MOUSEBUTTON}}(1) {{Cl|THEN}} {{Cl|LINE}} (PX, PY)-(X, Y), 15
{{Cl|IF}} {{Cl|_MOUSEBUTTON}}(2) {{Cl|THEN}} {{Cl|LINE}} (101, 11)-(599, 399), 8, BF
{{Cl|END IF}}
{{Cl|END IF}}
PX = X: PY = Y
{{Cl|LOCATE}} 28, 10: {{Cl|PRINT USING}} tm$; X; Y; {{Cl|_MOUSEBUTTON}}(1); {{Cl|_MOUSEBUTTON}}(2); {{Cl|_MOUSEBUTTON}}(3)
{{Cl|LOOP}}
{{Cl|LOOP}} {{Cl|UNTIL}} K$ = {{Cl|CHR$}}(27)
{{Cl|SYSTEM}} '' ''
{{CodeEnd}}
{{PageSeeAlso}}
* [[_MOUSEY]]
* [[_MOUSEBUTTON]], [[_MOUSEWHEEL]]
* [[_MOUSEINPUT]], [[_MOUSEMOVE]]
* [[_MOUSESHOW]], [[_MOUSEHIDE]]
* [[_MOUSEMOVEMENTX]], [[_MOUSEMOVEMENTY]] {{text|(relative pointer moves)}}
* [[Controller Devices]]
{{PageNavigation}}
<