Hi all,
I am looking for a method to simulate a button gadget is pressed. I searched the forum and found this command :
"PB_Gadget_SendGadgetCommand(GadgetID(#Gadget), #PB_EventType_LeftClick)"
However, it seems this command is no longer available, any suggestion?
Thanks
Allen
Simulate button gadget is pressed
Re: Simulate button gadget is pressed
something like this
Code: Select all
Procedure SetClick()
PostEvent(#PB_Event_Gadget ,0,1,#PB_EventType_LeftClick)
EndProcedure
Procedure GotClick()
Debug "gotclick"
EndProcedure
If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 200, 20, "Send click to button")
ButtonGadget(1, 10, 40, 200, 20, "Button", #PB_Button_Left)
BindGadgetEvent(0,@SetClick(),#PB_EventType_LeftClick)
BindGadgetEvent(1,@gotClick(),#PB_EventType_LeftClick)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Simulate button gadget is pressed
Hi Idle,
Thanks you for the example, it is what I am looking for.
Thanks
Allen
Thanks you for the example, it is what I am looking for.
Thanks
Allen
Re: Simulate button gadget is pressed
PB_Gadget_SendGadgetCommand still working here:
using PB6.20b1
Code: Select all
Import ""
PB_Gadget_SendGadgetCommand(hWnd, EventType)
EndImport
Procedure SetClick()
PB_Gadget_SendGadgetCommand(GadgetID(1), #PB_EventType_LeftClick)
EndProcedure
Procedure GotClick()
Debug "gotclick"
EndProcedure
If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 200, 20, "Send click to button")
ButtonGadget(1, 10, 40, 200, 20, "Button", #PB_Button_Left)
BindGadgetEvent(0,@SetClick(),#PB_EventType_LeftClick)
BindGadgetEvent(1,@gotClick(),#PB_EventType_LeftClick)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
PureBasic: Surprisingly simple, diabolically powerful
Re: Simulate button gadget is pressed
Not used. Is implemented as a PostEvent
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Simulate button gadget is pressed
PostEvent() is better than relying on undocumented internals