_TITLE "MBS (Mouse Button Status) by Steve" ' 12-17-2020
held$ = ""
result = MBS
left
= left
- (result
AND 8) \
8 right
= right
- (result
AND 16) \
16 middle
= middle
- (result
AND 32) \
32
PRINT "Left pressed : "; left
PRINT "Right pressed : "; right
PRINT "Middle pressed: "; middle
PRINT "Mouse Wheel Scrolled: "; scroll
PRINT "Last held event started at X/Y :"; Mouse_StartX
, Mouse_StartY
PRINT "Last held event ended at X/Y :"; Mouse_EndX
, Mouse_EndY
CONST ClickLimit##
= 0.2 'Less than 1/4th of a second to down, up a key to count as a CLICK. ' Down longer counts as a HOLD event.
SHARED Mouse_StartX
, Mouse_StartY
, Mouse_EndX
, Mouse_EndY
WHILE _MOUSEINPUT 'Remark out this block, if mouse main input/clear is going to be handled manually in main program.
IF _MOUSEBUTTON(1) THEN 'If a button is pressed, start the timer to see what it does (click or hold) ButtonDown
= 1: StartTimer
= TIMER(0.01) ButtonDown
= 2: StartTimer
= TIMER(0.01) ButtonDown
= 3: StartTimer
= TIMER(0.01) IF TIMER(0.01) - StartTimer
<= ClickLimit
THEN 'Button was down, then up, within time limit. It's a click MBS = 0: ButtonDown = 0: StartTimer = 0
ELSE 'We've now started the hold event MBS
= MBS
OR 32 * 2 ^ ButtonDown