Difference between revisions of "MOUSEWHEEL"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 41: Line 41:
 
   {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
 
   {{Cl|DO...LOOP|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}
 
     row = row + {{Cl|_MOUSEWHEEL}}
 
     row = row + {{Cl|_MOUSEWHEEL}}
     {{Cl|IF...THEN|IF}} prevrow <> row {{Cl|THEN}}
+
     {{Cl|IF...THEN|IF}} prevrow <> row {{Cl|THEN}} 'look for a change in row value
 
       {{Cl|IF...THEN|IF}} row > 0 {{Cl|AND (boolean)|AND}} row <= inputcount - 20 {{Cl|THEN}}
 
       {{Cl|IF...THEN|IF}} row > 0 {{Cl|AND (boolean)|AND}} row <= inputcount - 20 {{Cl|THEN}}
 
         {{Cl|CLS}}: {{Cl|LOCATE}} 2, 1
 
         {{Cl|CLS}}: {{Cl|LOCATE}} 2, 1
Line 49: Line 49:
 
       {{Cl|END IF}}
 
       {{Cl|END IF}}
 
     {{Cl|END IF}}
 
     {{Cl|END IF}}
     prevrow = row
+
     prevrow = row 'store previous row value
 
   {{Cl|LOOP}}
 
   {{Cl|LOOP}}
 
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > ""
 
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} > ""

Revision as of 07:23, 3 January 2011

The _MOUSEWHEEL function returns a positive or negative INTEGER value indicating the mouse scroll wheel clicks since the last mouse read.


Syntax

scroll% = _MOUSEWHEEL


Description

  • Positive return value of 1 represents one "click" the mouse wheel was moved toward the user.
  • Negative return value of -1 represents one "click" the mouse wheel was moved away from the user.
  • After a "click" has been read, the value resets to 0 automatically.
  • If no movement on the wheel has occurred since the last _MOUSEINPUT read, _MOUSEWHEEL returns 0.
  • You may want to use a cumulative mouse wheel scroll value using a total variable.


Example 1: Reading the cumulative mouse wheel "clicks" (Enter quits).

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.

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 row = row + _MOUSEWHEEL 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



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page