FUNCTION MOUSEBTN AS BYTE () SHARED STATIC
You can check whether an a bit is set using the AND
operator. For example:
IF MOUSEBTN() AND 1 THEN PRINT "left" IF MOUSEBTN() AND 2 THEN PRINT "right" IF MOUSEBTN() AND 4 THEN PRINT "middle"
INCLUDE "x16.bas" DIM btn AS BYTE CALL MOUSEON() PRINT "click left or middle button to get position" PRINT "or right button to exit" DO btn = MOUSEBTN() ' No button IF btn = 0 THEN CONTINUE DO ' Right button IF btn AND 2 THEN CALL MOUSEOFF() : END ' Any other button(s) PRINT "x: "; MOUSEX(), "y: "; MOUSEY() ' Now wait until the button is released DO : LOOP UNTIL MOUSEBTN() = 0 LOOP WHILE 1