TGC Codebase Backup



detect mouse double click by Phaelax

15th Sep 2003 20:04
Summary

I saw another example of this, but this uses much less code to detect for a double mouse click. I wrote it some time ago cause someone requested it.



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM Returns 1 if the user has double clicked the mouse, otherwise returns 0.
REM clickDelay must be of type integer and represents the delay between
REM clicks in milliseconds.
REM The following can be used to get the delay the user has set for Windows.
REM 
REM load dll "user32.dll",1
REM clickDelay=call dll(1,"GetDoubleClickTime")

function _double_click(clickDelay)
  _d_c=0 
  if mouseclick() = 0 then flag=0
  if mouseclick() and NOC=0 and flag=0 then NOC=1:clickOne#=timer():flag=1
  if mouseclick() and NOC=1 and flag=0 then _d_c=1:flag=1:NOC=0
  if timer() > clickOne#+clickDelay then NOC=0
endfunction _d_c