Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best Double Click method....
#6
https://qb64phoenix.com/forum/showthread.php?tid=138  <-- My MBS routine.  (Mouse Button Status)

It doesn't do double clicks natively, but it does give you clicks and once you have those, the code for double clicks is rather trivial to add.  (It does the all important click, hover, hold, drag events for us.)

Code: (Select All)

Do
   result = mbs
   if result = 1 then 'right mouse click, check results
          click = click + 1
          if click = 2 then 
               tick_timer = 0 'no need to wait any longer; we have our double click already
           else
               tick_timer = TIMER(0.001) + 0.2  'two tenths of a second to double click 
           end if
   end if
   if click then
       if TIMER > tick_timer then 'we've passed that 0.2 seconds of time for a double click
           if click = 2 then
                'it's a double click
           else then
                'it's a single click click
           end if
       end if
       click = 0: tick_timer = 0 'reset counter and timer
   end if 
LOOP


untested pseudocode written on my ipad, so it may need a little tweaking, but that's the general concept behind the process.

Get a click... start a timer.  If you get a second click in the allotted time, it's a double click.  If the time passes without that second click coming, it's a single click.

MBS works good with this simple little code as it already deals with the hold events and such for us.  I *could* add in the double-click to the routine, but it honestly seemed unnecessary and just something extra to track and process when most programs don't need it.  It's easy enough to add into a program, like above, for those cases where a double click is actually warranted.
Reply


Messages In This Thread
Best Double Click method.... - by Unseen Machine - 10-30-2025, 12:36 AM
RE: Best Double Click method.... - by Pete - 10-30-2025, 03:20 AM
RE: Best Double Click method.... - by Pete - 10-30-2025, 03:53 AM
RE: Best Double Click method.... - by SMcNeill - 10-30-2025, 05:53 AM
RE: Best Double Click method.... - by Pete - 10-30-2025, 08:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Double slit experiment vince 7 1,682 07-18-2024, 11:06 PM
Last Post: Pete
  Click Away Balls bplus 6 1,577 05-16-2022, 01:04 PM
Last Post: Dav

Forum Jump:


Users browsing this thread: 1 Guest(s)