And here's a more elaborate mouse routine:
count = count + 1
Box(count).x = i
Box(count).y = 100
Box
(1).
Color = &HFFFF0000Box
(2).
Color = &HFF00FF00Box
(3).
Color = &HFF0000FF
IF OMB
= 0 THEN 'The mouse button was up on a previous pass held
= TIMER(0.001) - t#
'check to see if the button is held down for .2 seconds or more IF held
> 0.2 THEN EXIT WHILE 'After .2 seconds, we declare this a "hold event"
IF held
< 0.2 THEN 'if we're not held down, it's a click Box(i).Click = Box(i).Click + 1
ELSE ' If we're held down, let's store the original coordinates of the box we're held over (if any) BO = 0
IF StartX
>= Box
(i
).x
AND StartX
<= Box
(i
).x
+ 100 AND StartY
>= Box
(i
).y
AND StartY
<= Box
(i
).y
+ 100 THEN BOX = Box(i).x: BOY = Box(i).y 'Box Original X and Box Original Y
BO = i 'Box the mouse is Over
ELSE 'If the button was down on a previous pass, we'll deal with a "hold button" event, if we have one. IF StartX
>= BOX
AND StartX
<= BOX
+ 100 AND StartY
>= BOY
AND StartY
<= BOY
+ 100 THEN 'we held the mouse down over a box Box(BO).x = BOX - Xshift
Box(BO).y = BOY - Yshift
For this sample, click on the boxes just as you did before, and you can see how we interact with a "click event".
Then click on a box and hold the mouse down and move it across the screen. You can see how we'd deal with a "mouse down/ drag event".
In either case, our main routine for mouse handling is:
If you notice, I *do* have a routine in this code which looks rather similar to the one you posted:
held
= TIMER(0.001) - t#
'check to see if the button is held down for .2 seconds or more
The difference here?
The main process handles all the real mouse input work, and I only trap the input for 2/10ths of a second, so I can to see if I'm dealing with a "click event", or starting a "hold button" event. The "WHILE _MOUSEINPUT: WEND" keeps the mousebuffer clear for us, and stops the input backlog from building up like we saw in the very first little demo I showcased above.
"WHILE _MOUSEINPUT: WEND" is normally your main mouse loop, and the only thing you normally see inside it might be a counter if you're tracking the mouse scroll status. ;)