Set an option Gadget without triggering an event?
Set an option Gadget without triggering an event?
How I set option gadgets (for example after loading a user setting) without triggering an gadget event? An gadget event should only happened if the user click the gadget
Re: Set an option Gadget without triggering an event?
It doesn't do that by default, so something in your event code is doing it by mistake. Proof:
Code: Select all
If OpenWindow(0, 300, 200, 140, 110, "OptionGadget", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 20, 120, 20, "Click to set options")
OptionGadget(1, 10, 45, 120, 20, "Option 1")
OptionGadget(2, 10, 70, 120, 20, "Option 2")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0 : n+1 : If n=3 : n=1 : EndIf : SetGadgetState(n,1) ; Button
Case 1,2 : Debug "This doesn't show when the Button sets it" ; Options
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Set an option Gadget without triggering an event?
Code: Select all
SetGadgetState(10, 1) ; set option 10 as active one
debug GetGadgetState(10) ;get status of option gadget 10
Egypt my love
Re: Set an option Gadget without triggering an event?
Hm... strange. I definitely get an event from this gadget after SetGadgetState() in my code. If I comment the line with SetGadgetState() I do not get an event from the gadget....
Re: Set an option Gadget without triggering an event?
I am not sure but you can try
SetGadgetData() - GetGadgetData() 1 for active 0 for no
Still I do not know what is your problem exactly
SetGadgetData() - GetGadgetData() 1 for active 0 for no
Still I do not know what is your problem exactly
Egypt my love
Re: Set an option Gadget without triggering an event?
HM ...
No Event by SetGadgetState on
PB: v5.73 (x64)
OS: MacOS, Window 7 Pro, Windows 10 Pro (1909), Ubuntu 18.04 LTS
Edit: With own event ...
No Event by SetGadgetState on
PB: v5.73 (x64)
OS: MacOS, Window 7 Pro, Windows 10 Pro (1909), Ubuntu 18.04 LTS
Edit: With own event ...
Code: Select all
If OpenWindow(0, 300, 200, 140, 110, "OptionGadget", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 20, 120, 20, "Click to set options")
OptionGadget(1, 10, 45, 120, 20, "Option 1")
OptionGadget(2, 10, 70, 120, 20, "Option 2")
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0 : n+1 : If n=3 : n=1 : EndIf : SetGadgetState(n,1) : PostEvent(#PB_Event_Gadget, EventWindow(), n, #PB_EventType_FirstCustomValue) ; Button
Case 1,2 :
Debug "OptionGadget " + EventGadget() ; Options
Select EventType()
Case #PB_EventType_LeftClick
Debug "Change from User"
Case #PB_EventType_FirstCustomValue
Debug "Change from SetGadgetState"
EndSelect
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Last edited by mk-soft on Fri Dec 04, 2020 4:13 pm, edited 1 time in total.
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: Set an option Gadget without triggering an event?
Set OptionGadget() status without triggering it's event
Code: Select all
If OpenWindow(0, 0, 0, 140, 150, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OptionGadget(0, 30, 20, 60, 20, "Option 1")
OptionGadget(1, 30, 45, 60, 20, "Option 2")
OptionGadget(2, 30, 70, 60, 20, "Option 3")
ButtonGadget(10,10,110,80,20,"Update")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug "OK"
Case 10
SetGadgetState(1,1)
EndSelect
EndSelect
Until Quit = 1
EndIf
Egypt my love
Re: Set an option Gadget without triggering an event?
Without seeing your code, we can't see what you've done wrong. Try to post a small snippet showing the problem.Lebostein wrote:I definitely get an event from this gadget after SetGadgetState() in my code