I've found that typing the same Do while _mouseinput .... loop commands gets quite tedious after a bit. My solution: Make a function, include it in an easy to load library, and use it to forever make checking the mouse easier.
DEFINT A-Z
DO
mbs = mouseclick 'mbs is short for mousebuttonstatus. This statement checks to see what is going on with the mouse buttons.
LOCATE 1, 1
SELECT CASE mbs
CASE 0: PRINT "left mouse clicked "
CASE 1: PRINT "right mouse clicked "
CASE 2: PRINT "left button double clicked "
CASE 3: PRINT "right button double clicked "
CASE 4: PRINT "pressed the middle button "
CASE 5: PRINT "middle button double pressed "
CASE 6: PRINT "scrolled mouse wheel ";: scroll% = scroll% + 1: PRINT scroll%; "times "
CASE 7: PRINT "scrolled mouse wheel ";: scroll% = scroll% - 1: PRINT scroll%; "times "
END SELECT
LOCATE 10, 1: PRINT "Press <ANY KEY> to quit"
a$ = INKEY$
LOOP UNTIL a$ <> ""
END
'***********************************
'* Copy from here down and
'* save and place in a library file
'* for a quick mouse button function
'* if you thiink this is useful
'***********************************
FUNCTION mouseclick%
mouseclick% = -1
DO WHILE _MOUSEINPUT 'check mouse status
lb% = _MOUSEBUTTON(1): rb% = _MOUSEBUTTON(2) 'see if left or right button are pushed down
mb% = _MOUSEBUTTON(3) 'if mouse has 3 buttons, this will check the middle one
scroll% = scroll% + _MOUSEWHEEL ' if scrollwheel changes, watch the change here
LOOP
DO WHILE lb% 'check for leftbutton release
i% = _MOUSEINPUT
lb% = _MOUSEBUTTON(1)
mouseclick% = 0
LOOP
DO WHILE rb% 'check for right button release
i% = _MOUSEINPUT
rb% = _MOUSEBUTTON(2)
mouseclick% = 1
LOOP
DO WHILE mb% 'check for middle button release
i% = _MOUSEINPUT
mb% = _MOUSEBUTTON(3)
mouseclick% = 4
LOOP
IF mouseclick% > -1 THEN 'if button was pressed and released
t! = TIMER + .25
DO WHILE TIMER < t! 'check for a second press within .25 seconds
i% = _MOUSEINPUT
IF _MOUSEBUTTON(1) AND mouseclick% = 0 THEN mouseclick% = 2: EXIT DO
IF _MOUSEBUTTON(2) AND mouseclick% = 1 THEN mouseclick% = 3: EXIT DO
IF _MOUSEBUTTON(3) AND mouseclick% = 4 THEN mouseclick% = 5: EXIT DO
LOOP
END IF
IF scroll% < 0 THEN mouseclick% = 6
IF scroll% > 0 THEN mouseclick% = 7
END FUNCTION
Simply do a MBS% = mouseclick%, and the return result is whatever is going on with the mousebuttons. I've only got this set up for 3 mouse buttons, and the scroll wheel (as that's all I have myself on my mouse), but it'd be easy enough to expand the function to give a result for more mouse buttons, if your program is something that needs a more clickable mouse.
Personally, I think all QB64 libraries need a quick funtion like this for easy mouse button checking.
