No #PB_EventType_Change for OptionGadget

Everything else that doesn't fall into one of the other PB categories.
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

No #PB_EventType_Change for OptionGadget

Post by jacdelad »

Hello,
ist there a particular reason, why there's no #PB_EventType_Change for OptionGadgets? I searched Google and didn't find information about this being asked before, though it seems like a logical thing for me.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
BarryG
Addict
Addict
Posts: 4174
Joined: Thu Apr 18, 2019 8:17 am

Re: No #PB_EventType_Change for OptionGadget

Post by BarryG »

I agree that a change event should occur when their status changes from on/off, but then the new gadget would be the EventGadget() and not the previous OptionGadget whose on/off state just changed. So it's probably not possible?

You have to detect it something like this:

Code: Select all

If OpenWindow(0, 300, 300, 140, 110, "OptionGadget", #PB_Window_SystemMenu)
  OptionGadget(0, 30, 20, 60, 20, "Option 1")
  OptionGadget(1, 30, 45, 60, 20, "Option 2")
  OptionGadget(2, 30, 70, 60, 20, "Option 3")
  SetGadgetState(1, 1)
  oldgad=-1
  Repeat
    ev=WaitWindowEvent()
    If ev=#PB_Event_Gadget
      newgad=EventGadget()
      If newgad<>oldgad
        oldgad=newgad
        If GadgetType(newgad)=#PB_GadgetType_Option
          Debug "changed"
        EndIf
      EndIf
    EndIf
  Until ev=#PB_Event_CloseWindow
EndIf
User avatar
jacdelad
Addict
Addict
Posts: 2010
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: No #PB_EventType_Change for OptionGadget

Post by jacdelad »

Well, a change would occur in the new gadget. The programmer has to take care of it anyway (and can get the status with GetGadgetState()). Also, only one OptionGadget of a group can be activated, so I store a value in a variable, which indicates which OptionGadget is activated. If the new one sends a Change-Message I overwrite the value and don't need to check the other gadgets anyway.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply