Page 1 of 1

Doubleclick on OptionGadget?

Posted: Tue Sep 23, 2003 3:58 pm
by ebs
I know it's non-standard, but is there an easy way to detect a left doubleclick on an OptionGadget?

Posted: Tue Sep 23, 2003 7:17 pm
by Henrik
hi
Well it's ugly fast stunt i could come up with, but it's a worke around for now.
i'am pretty sure one of the better coders can come up with something
better.
there is some win api stuf like
GetDoubleClickTime
SetDoubleClickTime
but i duno mush about you should look it up

nb. Dbc=gettickcount_()+150 ;<< ajust this for DoubleClickTime you want

Code: Select all


#Window_0 = 0

#Gadget_0 = 0
#Gadget_1 = 1
#Gadget_2 = 2


Procedure Open_Window_0()
    If OpenWindow(#Window_0, 216, 0, 252, 196,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "DoubleClick")
        If CreateGadgetList(WindowID())
            OptionGadget(#Gadget_0, 37, 25, 54, 25, "Test")
            OptionGadget(#Gadget_1, 104, 26, 54, 25, "Test2")
            StringGadget(#Gadget_2, 34, 75, 137, 32, "nothing yet")
        EndIf
    EndIf
EndProcedure

Open_Window_0()

Repeat
    
    If gettickcount_() >Dbc:DBClk=0:EndIf
        EventID = WaitWindowEvent()
        If EventID = #WM_LBUTTONDBLCLK
            DBClk=1
            Dbc=gettickcount_()+150 ;<< ajust this for DoubleClickTime you want
        Else
            
        EndIf
        
        If EventID = #PB_EventGadget
            
            GadgetID = EventGadgetID()
            
            If GadgetID = #Gadget_0  And DBClk=0
                SetGadgetText(#Gadget_2, "Test1 One Click")
            ElseIf GadgetID = #Gadget_0 And DBClk=1
                SetGadgetText(#Gadget_2, "Test1 DoubleClick**")
                
            ElseIf GadgetID = #Gadget_1 And DBClk=0
                SetGadgetText(#Gadget_2, "Test2 One Click")
            ElseIf GadgetID =  #Gadget_1 And DBClk=1
                SetGadgetText(#Gadget_2, "Test2 DoubleClick**")
                
            EndIf
            
            
        EndIf
        
    Until EventID = #PB_EventCloseWindow

best regards
Henrik
>edit inline asm didn't like Db so it was remaned to Dbc<

Posted: Wed Sep 24, 2003 2:43 am
by PB
> Dbc=gettickcount_()+150 ;<< ajust this for DoubleClickTime you want

Just replace the above line with:

Code: Select all

Dbc=gettickcount_()+GetDoubleClickTime_()
:)

Posted: Wed Sep 24, 2003 4:34 pm
by Henrik
Hehe :o :lol:
Why on earth did'nt i just try it out :?:
/note to self: Sometimes, when it looks simple it maybe is simple. tsk tsk :)
PB wrote: Just replace the above line with:

Code: Select all

Dbc=gettickcount_()+GetDoubleClickTime_()
:)