mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-19 22:35:24 +00:00
58 lines
2.2 KiB
Text
58 lines
2.2 KiB
Text
|
The '''_MOUSEMOVEMENTX''' function returns the relative horizontal position of the mouse cursor as positive or negative values.
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
::: verticalmove = '''_MOUSEMOVEMENTY'''
|
||
|
|
||
|
|
||
|
* Returns the relative horizontal cursor pixel position compared to the previous cursor position. Negative values are moves to the left.
|
||
|
* '''Hides the mouse cursor''' once it is inside of the program window area. This may lead to some ''"confusion"'' by the user!
|
||
|
* '''Note:''' A [[_MOUSESHOW]] statement will disable [[_MOUSEMOVEMENTX]] or [[_MOUSEMOVEMENTY]] relative mouse movement reads.
|
||
|
* Can also be used to check for any mouse movements to enable a program or close [[Screen Saver Programs]].
|
||
|
|
||
|
|
||
|
''Example 1:'' Since values returned are relative to the last position, the returns can be positive or negative.
|
||
|
{{CodeStart}} '' ''
|
||
|
{{Cl|SCREEN}} 12
|
||
|
PX = 320: PY = 240 'center position
|
||
|
{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 200
|
||
|
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
|
||
|
PX = PX + {{Cl|_MOUSEMOVEMENTX}}
|
||
|
PY = PY + {{Cl|_MOUSEMOVEMENTY}}
|
||
|
{{Cl|LOOP}}
|
||
|
{{Cl|CLS}}
|
||
|
{{Cl|CIRCLE}} (PX, PY), 10, 10
|
||
|
{{Cl|LOCATE}} 1, 1: {{Cl|PRINT}} PX, PY
|
||
|
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27) 'escape key exit '' ''
|
||
|
{{CodeEnd}}
|
||
|
|
||
|
|
||
|
''Example 2:'' MOD is used to keep horizontal movement of the circle and cursor inside of the SCREEN 13 window(320).
|
||
|
{{CodeStart}} '' ''
|
||
|
{{Cl|SCREEN}} 13, , 1, 0
|
||
|
{{Cl|DO...LOOP|DO}}: {{Cl|_LIMIT}} 200
|
||
|
{{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
|
||
|
x = x + {{Cl|_MOUSEMOVEMENTX}}
|
||
|
y = y + {{Cl|_MOUSEMOVEMENTY}}
|
||
|
{{Cl|LOOP}}
|
||
|
x = (x + 320) {{Cl|MOD}} 320 'keeps object on screen
|
||
|
y = (y + 200) {{Cl|MOD}} 200 'remove if off screen moves are desired
|
||
|
{{Cl|CLS}}
|
||
|
{{Cl|CIRCLE}} (x, y), 20
|
||
|
{{Cl|PCOPY}} 1, 0
|
||
|
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} <> "" 'press any key to exit '' ''
|
||
|
{{CodeEnd}}
|
||
|
: '''NOTE: '''When using the function this way, give the user a keypress exit option! Make sure the user has some way to exit that is not dependent on clicking the X button!
|
||
|
|
||
|
|
||
|
''See also:''
|
||
|
* [[_MOUSEMOVEMENTY]]
|
||
|
* [[_MOUSEINPUT]], [[_MOUSEX]]
|
||
|
* [[_DEVICES]], [[_DEVICEINPUT]]
|
||
|
* [[_WHEEL]], [[_LASTWHEEL]]
|
||
|
* [[_AXIS]], [[_LASTAXIS]]
|
||
|
* [[_MOUSESHOW]], [[_MOUSEHIDE]]
|
||
|
* [[Screen Saver Programs]]
|
||
|
|
||
|
|
||
|
{{PageNavigation}}
|