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

Just starting out? Need help? Post your questions and find answers here.
stbi
New User
New User
Posts: 3
Joined: Thu Mar 31, 2005 10:27 am
Location: Stuttgart, Germany

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

Post 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
ebs
Enthusiast
Enthusiast
Posts: 558
Joined: Fri Apr 25, 2003 11:08 pm

Post 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
Post Reply