Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 038: _MOUSEWHEEL
#1
Pretty simple...

SYNTAX scrollAmount% = _MOUSEWHEEL

Usage: Track the scrolling increments of the mouse wheel.

Example:
Code: (Select All)
DIM x AS INTEGER
DO
    _LIMIT 30
    WHILE _MOUSEINPUT
        x = x + _MOUSEWHEEL ' Must be placed inside WHILE/WEND loop.
    WEND
    lb = _MOUSEBUTTON(1) ' Left mouse button. Better placed outside of WHILE/WEND loop.
    IF lb THEN x = 0 ' reset mousewheel counter.
    LOCATE 1, 1: PRINT x; " ";
LOOP


One thing to keep in mind is unlike most of the other _MOUSE... keywords, _MOUSEWHEEL has to be placed between WHILE _MOUSEINPUT and WEND statements to be read, not after it like the _MOUSEBUTTON statements.

Note: _MOUSEMOVEX and _MOUSEMOVEY is another example of _MOUSE keywords which need to b placed between, not after, the WHILE/WEND _MOUSEINPUT loop.


Now if you only want to know the direction of the mouse wheel, use SGN() as in...

Code: (Select All)
DIM AS INTEGER x, sgnx
DO
    _LIMIT 30
    WHILE _MOUSEINPUT
        x = x + _MOUSEWHEEL
    WEND
    lb = _MOUSEBUTTON(1) ' Left mouse button.
    IF lb THEN x = 0 ' reset mousewheel counter.
    sgnx = SGN(x - oldx): oldx = x
    LOCATE 1, 1: PRINT x; " ";: IF sgnx THEN PRINT sgnx; "  ";: IF sgnx = -1 THEN PRINT "Up  "; ELSE PRINT "Down"; "   ";
LOOP

Pete
Reply




Users browsing this thread: 1 Guest(s)