Code archives/Miscellaneous/Detecting Doubleclicks
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
An example of how to detect a mouse doubleclick. Points to note: It waits for the doubleclick period to expire before it reports a singleclick. | |||||
Doubleclicktime=250 Repeat Doubleclick1=False click1=False Time=MilliSecs() If MouseDown(1) Then mousedown1 = True Else If mousedown1 Then ; if we get here mouse button has been released Clicktime1 = Time If Clicktime1-Lastclicktime1 <= Doubleclicktime Then Doubleclick1=True Lastclicktime1=0 : Wait1time=0 Else If Wait1time=0 Then Wait1time = Clicktime1 + doubleclicktime Lastclicktime1 = Clicktime1 EndIf mousedown1 = False EndIf EndIf If Wait1time > 0 And Time > Wait1time Then Click1 = True : Wait1time=0 If Click1 Then click1count=click1count+1 : Print clicktime1+" singleclick "+click1count If doubleclick1 Then double1count=double1count+1 : Print Clicktime1+" Doubleclick! "+double1count Until KeyDown(1) End |
Comments
None.
Code Archives Forum