====== MOUSEBTN ====== [x16] //Defined in [[x16.bas]].// Returns the mouse button state as a BYTE. ===== Function header ===== FUNCTION MOUSEBTN AS BYTE () SHARED STATIC * If the left button is pressed, Bit #0 is set * If the right button is pressed, Bit #1 is set * If the middle button is pressed, Bit #2 is set 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" ===== Example ===== 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 ===== See also ===== * [[MOUSEON]] * [[MOUSEOFF]] * [[MOUSEX]] * [[MOUSEY]]