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: 1437
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
BarryG
Addict
Addict
Posts: 3294
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: 1437
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

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.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply