MOUSEWHEEL: Difference between revisions
Jump to navigation
Jump to search
Code by Ted Weissgerber
Note: You will need a text file that is large enough for this example.
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
Line 11: | Line 11: | ||
* After an event has been read, the value resets to 0 automatically so cumulative position values must be added. | * After an event has been read, the value resets to 0 automatically so cumulative position values must be added. | ||
* If no movement on the wheel has occurred since the last [[_MOUSEINPUT]] read, [[_MOUSEWHEEL]] returns 0. | * If no movement on the wheel has occurred since the last [[_MOUSEINPUT]] read, [[_MOUSEWHEEL]] returns 0. | ||
* '''[[ | * '''[[Keywords currently not supported by QB64#Keywords not supported in Linux or macOS versions|Keyword not supported in macOS versions]]''' | ||
{{PageAvailability}} | |||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''v0.851''' | |||
File:Qbpe.png|'''all''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''no''' | |||
</gallery> | |||
Line 22: | Line 33: | ||
LOCATE 10, 20: PRINT Scroll | LOCATE 10, 20: PRINT Scroll | ||
LOOP | LOOP | ||
LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit | LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit | ||
{{CodeEnd}} | {{CodeEnd}} | ||
Line 52: | Line 63: | ||
prevrow = row 'store previous row value | prevrow = row 'store previous row value | ||
{{Cl|LOOP}} | {{Cl|LOOP}} | ||
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" | {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > "" | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{small|Code by Ted Weissgerber}} | {{small|Code by Ted Weissgerber}} | ||
Line 60: | Line 71: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]] | * [[_MOUSEX]], [[_MOUSEY]], [[_MOUSEBUTTON]] | ||
* [[_MOUSEINPUT]], [[_MOUSEMOVE]] | * [[_MOUSEINPUT]], [[_MOUSEMOVE]] | ||
* [[_MOUSESHOW]], [[_MOUSEHIDE]] | * [[_MOUSESHOW]], [[_MOUSEHIDE]] | ||
* [[Controller Devices]] | * [[Controller Devices]] |
Revision as of 02:08, 23 January 2023
The _MOUSEWHEEL function returns a positive or negative INTEGER value indicating mouse scroll events since the last read of _MOUSEINPUT.
Syntax
- scrollAmount% = _MOUSEWHEEL
Description
- Returns -1 when scrolling up and 1 when scrolling down with 0 indicating no movement since last read.
- After an event has been read, the value resets to 0 automatically so cumulative position values must be added.
- If no movement on the wheel has occurred since the last _MOUSEINPUT read, _MOUSEWHEEL returns 0.
- Keyword not supported in macOS versions
Availability
Examples
Example 1: Reading the cumulative mouse wheel "clicks".
DO: _LIMIT 100 DO WHILE _MOUSEINPUT Scroll = Scroll + _MOUSEWHEEL LOCATE 10, 20: PRINT Scroll LOOP LOOP UNTIL INKEY$ = CHR$(13) ' press Enter to quit |
Example 2: A simple text scrolling routine using the mouse wheel value to read a text array.
DIM Array$(100) LINE INPUT "Enter a file name with 100 or more lines of text: ", file$ OPEN file$ FOR INPUT AS #1 DO UNTIL EOF(1) inputcount = inputcount + 1 LINE INPUT #1, Array$(inputcount) IF inputcount = 100 THEN EXIT DO LOOP FOR n = 1 TO 21: PRINT Array$(n): NEXT CLOSE #1 DO DO WHILE _MOUSEINPUT IF row >= 0 THEN row = row + _MOUSEWHEEL ELSE row = 0 'prevent under scrolling IF row > inputcount - 20 THEN row = inputcount - 20 'prevent over scrolling IF prevrow <> row THEN 'look for a change in row value IF row > 0 AND row <= inputcount - 20 THEN CLS: LOCATE 2, 1 FOR n = row TO row + 20 PRINT Array$(n) NEXT END IF END IF prevrow = row 'store previous row value LOOP LOOP UNTIL INKEY$ > "" |
See also