Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to manage with efficacy the mouse input...
#8
(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.
Reply


Messages In This Thread
RE: How to manage with efficacy the mouse input... - by SMcNeill - 11-18-2025, 01:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating my Mouse/Keyboard/Buttons/Fields routine. Pete 36 5,513 04-03-2025, 11:26 PM
Last Post: Pete
  seperate input from multiple mice v0.54 graphic demo madscijr 1 704 06-21-2024, 01:12 PM
Last Post: madscijr
  read 2 or more USB mice on one PC - fully working with keyboard input madscijr 2 1,114 06-16-2024, 01:48 AM
Last Post: madscijr
  IT'S ALIVE! reading seperate input from multiple mice plugged into one PC v0.30 madscijr 1 796 05-26-2024, 04:14 PM
Last Post: madscijr
  Mouse Routines to Use and Hack TerryRitchie 3 1,207 08-15-2023, 12:11 AM
Last Post: grymmjack

Forum Jump:


Users browsing this thread: 1 Guest(s)