Here's a handy double click function for everyone to enjoy.
The function:
global G_bMousePressed as boolean
global G_bFlag as boolean
global G_dwClickDelay as dword : G_dwClickDelay = 400
global G_dwTime as dword
global G_dwTimeDelay as dword
`----------------------------------------------------
` Sasuke's DoubleClick Function
`----------------------------------------------------
` Will return 1 if theres a double click with the left mouse button
function Mouse_DoubleClick()
local L_bDoubleClick as boolean
if mouseclick() = 1 and G_bMousePressed = 0 and G_bFlag = 0
G_dwTime = timer()
G_dwTimeDelay = G_dwTime + G_dwClickDelay
G_bFlag = 1
L_bDoubleClick = 0
G_bMousePressed = 1
endif
if G_bFlag = 1
G_dwTime = timer()
if G_dwTime > G_dwTimeDelay
G_bFlag = 0
else
if mouseclick() = 1 and G_bMousePressed = 0 and G_bFlag = 1
G_bFlag = 0
L_bDoubleClick = 1
G_bMousePressed = 1
exitfunction L_bDoubleClick
endif
endif
endif
if scancode() = 0 and mouseclick() = 0 then G_bMousePressed = 0
endfunction L_bDoubleClick
And a demo:
global G_bMousePressed as boolean
global G_bFlag as boolean
global G_dwClickDelay as dword : G_dwClickDelay = 400
global G_dwTime as dword
global G_dwTimeDelay as dword
r = 25 : g = 233 : b = 74
backdrop on
color backdrop rgb(r,g,b)
do
if Mouse_DoubleClick() > 0
r = r + 24 : g = g + 16 : b = b + 46
endif
if r >= 255 then r = 0 : if g >= 255 then g = 0 : if b >= 255 then b = 0
color backdrop rgb(r,g,b)
set text size 36
center text screen width()/2 , screen height()/2 , "Double Left Click To Change Backdrop Color"
loop
`----------------------------------------------------
` Sasuke's DoubleClick Function
`----------------------------------------------------
` Will return 1 if theres a double click with the left mouse button
function Mouse_DoubleClick()
local L_bDoubleClick as boolean
if mouseclick() = 1 and G_bMousePressed = 0 and G_bFlag = 0
G_dwTime = timer()
G_dwTimeDelay = G_dwTime + G_dwClickDelay
G_bFlag = 1
L_bDoubleClick = 0
G_bMousePressed = 1
endif
if G_bFlag = 1
G_dwTime = timer()
if G_dwTime > G_dwTimeDelay
G_bFlag = 0
else
if mouseclick() = 1 and G_bMousePressed = 0 and G_bFlag = 1
G_bFlag = 0
L_bDoubleClick = 1
G_bMousePressed = 1
exitfunction L_bDoubleClick
endif
endif
endif
if scancode() = 0 and mouseclick() = 0 then G_bMousePressed = 0
endfunction L_bDoubleClick