Page 1 of 1

How to distinguish between left/double click on same object?

Posted: Fri Aug 05, 2005 1:16 pm
by stbi
Problem: how can I distinguish between a left click and a double left click on the same object? On a left double click eventtype() reports first a left click, then a left double click.

I modified some sample code from this forum to show this. Click double on a line of the gadget and watch the debugger output:

Code: Select all

OpenWindow(0, 0, 0, 250, 300, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "EventType()") 

CreateGadgetList(WindowID(0)) 
ListViewGadget(0, 5, 5, 240, 250) 
For i=0 To 20 
  AddGadgetItem(0, -1, "line......"+Str(i)) 
Next 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      Break 
    Case #PB_Event_Gadget 
      Select EventGadgetID() 
        Case 0 
          Select EventType() 
            Case #PB_EventType_LeftClick : Debug "LeftClick" 
            Case #PB_EventType_LeftDoubleClick : Debug "LeftDoubleClick" 
          EndSelect 
      EndSelect    
  EndSelect 
ForEver   
In the german forum Batze found a workaround using time delays, but it works not very reliable.

Btw VB6 has the same problem.

Any idea, please?

Thanks,
Stefan

Posted: Fri Aug 05, 2005 1:49 pm
by ebs
Stefan,

As far as I know, this (left-click event followed by double-click event) is a characteristic of Windows, so all languages will have this problem.
In VB6, I used a method with time delays, as you described.
If you use the Windows double-click time interval as your delay value, you should be able to distinguish between single and double clicks reliably.

Regards,
Eric