(11-18-2025, 12:03 AM)TempodiBasic Wrote: The two way are different because Petr build up an event status system to trigger the action after gathering the mouse input. In the while Steve memorizes the previous status of mouse buttons for comparing with the actual current status of mouse buttons and activating the action when it is useful.
Note that I mainly just used the MB1 variable and such as your code was already set to use those. All my real mouse handling is in the WHILE _MOUSEINPUT: WEND loop. I just used MB1 because it's less typing than _MOUSEBUTTON(1), but the status of _MOUSEBUTTON(1) never changes to be different than the status of MB1.
My trick is to make certain to only count a NEW down event as a click, and not to check to see if the mouse is simply held down.
IF _MOUSEBUTTON(1) THEN... <-- This is *just* a down event. You hold the button down, it's going to trigger repeatedly and constantly.
IF _MOUSEBUTTON(1) AND NOT OLD_MOUSEBUTTON(1) THEN... <--- This says "If the mouse is now down, and it wasn't down on the previous loop", then it's a NEW mousedown event.
Code: (Select All)
FUNCTION Click
STATIC Old_MouseButton
WHILE _MOUSEINPUT: WEND 'update mouse button status
IF _MOUSEBUTTON(1) AND NOT Old_MouseButton THEN Click = _TRUE
Old_MouseButton = _MOUSEBUTTON(1)
END FUNCTION
See the log in the above?
Track the old mousebutton.
It's only a NEW click if the mouse *was* up, and then becomes *down*.
If the old button state was down... It's not a click, it's a hold. Only process the new clicks to do whatever you want.
It really is that simple of a logic at play.
Mouse has to have been up, and then go down, for it to be a new click to process.

