Page 1 of 1

[Done] 2.21 - optiongadget event

Posted: Sun May 05, 2019 5:29 am
by JCV
From the code below, please try to click each optiongadget.
Sometimes, 2 gadgets event are triggered.

Code: Select all
Procedure Clicked()
  Debug "Clicked"
  GadgetNumber = EventGadget()
  State = GetGadgetState(GadgetNumber)
  Debug  FormatDate("%hh:%ii:%ss ", Date()) + "Gadget: " + Str(GadgetNumber) +  " = " + Str(State)
EndProcedure

If OpenWindow(0, 0, 0, 140, 110, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OptionGadget(0, 30, 20, 100, 20, "Option 1")
  OptionGadget(1, 30, 45, 100, 20, "Option 2")
  OptionGadget(2, 30, 70, 100, 20, "Option 3")
  BindGadgetEvent(0, @Clicked())
  BindGadgetEvent(1, @Clicked())
  BindGadgetEvent(2, @Clicked())
EndIf

; Repeat : Until WaitWindowEvent(10) = #PB_Event_CloseWindow ; Works in PB correctly

Re: 2.21 - optiongadget event

Posted: Mon May 06, 2019 9:24 am
by munfraid
I think this happens, because there are two events: One OptionGadget switch from "on" to "off" and another OptionGadget vice versa. Only the very first click triggers just one event, because only one Gadget is affected.

But there should be the same behaviour in PB and SB.

Re: 2.21 - optiongadget event

Posted: Tue May 07, 2019 7:29 am
by JCV
Hi munfraid,
Yes I tried that since in manual it says it is grouped as one but events of all gadget are not triggered.
For now I used checkbox instead of optiongadget until it is fixed.

Re: 2.21 - optiongadget event

Posted: Tue May 07, 2019 8:48 am
by the.weavster
You could use GetGadgetState() as a conditional so your handler is only responding to the item that was selected not the one which was deselected.

Re: 2.21 - optiongadget event

Posted: Fri Aug 30, 2019 9:33 am
by Fred
Fixed.