Doubleclick on OptionGadget?

Everything else that doesn't fall into one of the other PB categories.
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Doubleclick on OptionGadget?

Post by ebs »

I know it's non-standard, but is there an easy way to detect a left doubleclick on an OptionGadget?
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post 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<
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

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

Just replace the above line with:

Code: Select all

Dbc=gettickcount_()+GetDoubleClickTime_()
:)
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post 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_()
:)
Post Reply