[PB6.21] Bug? All radio buttons become on

Post bugreports for the Linux version here
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

[PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

Heya,

On Windows 11 this works well, but on Ubuntu 24.04 all the radio buttons become on (selected).

It seems like a bug to me.

Code: Select all

  Procedure GadgetFit(MARCOAGPINTO_gadget)
  
    MARCOAGPINTO_x=GadgetX(MARCOAGPINTO_gadget)
    MARCOAGPINTO_y=GadgetY(MARCOAGPINTO_gadget)
    MARCOAGPINTO_w=GadgetWidth(MARCOAGPINTO_gadget)
    MARCOAGPINTO_h=GadgetHeight(MARCOAGPINTO_gadget)
    MARCOAGPINTO_w_new=GadgetWidth(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
    MARCOAGPINTO_h_new=GadgetHeight(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
  
    If MARCOAGPINTO_w<>MARCOAGPINTO_w_new Or MARCOAGPINTO_h<>MARCOAGPINTO_h_new
      ResizeGadget(MARCOAGPINTO_gadget,MARCOAGPINTO_x,MARCOAGPINTO_y,MARCOAGPINTO_w_new,MARCOAGPINTO_h_new)      
    EndIf
  
  EndProcedure    
  



OpenWindow(1,10,10,800,600,"Testing",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)    
OpenWindow(2,0,0,640,480,"About",#PB_Window_WindowCentered,WindowID(1))
DisableWindow(1,#True)


  x=10
  y=10
  
    default_gadget_height_radio=21
  
    OptionGadget(1,x,y,default_gadget_height_radio,default_gadget_height_radio,"")
    GadgetFit(1)
    x+GadgetWidth(1)+20+5
    TextGadget(1+1000,x,y,10,10,"Radio 1")
    GadgetFit(1+1000)
    
    OptionGadget(2,x,y,default_gadget_height_radio,default_gadget_height_radio,"")
    GadgetFit(2)
    x+GadgetWidth(2)+20+5
    TextGadget(2+1000,x,y,10,10,"Radio 2")
    GadgetFit(2+1000)
    
    OptionGadget(3,x,y,default_gadget_height_radio,default_gadget_height_radio,"")
    GadgetFit(3)
    x+GadgetWidth(3)+20+5
    TextGadget(3+1000,x,y,10,10,"Radio 3")
    GadgetFit(3+1000)
    
    OptionGadget(4,x,y,default_gadget_height_radio,default_gadget_height_radio,"")
    GadgetFit(4)
    x+GadgetWidth(4)+20+5
    TextGadget(4+1000,x,y,10,10,"Radio 4")
    GadgetFit(4+1000)
    
    OptionGadget(5,x,y,default_gadget_height_radio,default_gadget_height_radio,"")
    GadgetFit(5)
    x+GadgetWidth(5)+20+5
    TextGadget(5+1000,x,y,10,10,"Radio 5")
    GadgetFit(5+1000)
    
  

  okay=#False
  Repeat
      
    event=WaitWindowEvent()
      
     
    If event=#PB_Event_CloseWindow
      okay=#True     
    EndIf      
      

  Until okay=#True

    
  ; Close the About window and activate the main window
  DisableWindow(1,#False)
  CloseWindow(2)
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB6.21] Bug? All radio buttons become on

Post by Demivec »

The first time this function is called, a group is created and all following calls of OptionGadget() will add a gadget to this group. To finish the group, just create a gadget of another type.
IMHO this is not a big and it is according to the documentation.

Solution, create all of the OptionaGadgets in the same group first, then the TextGadgets that are near them.

Right now you are putting only one OptionGadget in each group because you follow each with a TextGadget. If there is only one OptionaGadget in a group it is will be on because one in each group has to be on.
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

Demivec wrote: Mon Jun 16, 2025 11:09 am
The first time this function is called, a group is created and all following calls of OptionGadget() will add a gadget to this group. To finish the group, just create a gadget of another type.
IMHO this is not a big and it is according to the documentation.

Solution, create all of the OptionaGadgets in the same group first, then the TextGadgets that are near them.

Right now you are putting only one OptionGadget in each group because you follow each with a TextGadget. If there is only one OptionaGadget in a group it is will be on because one in each group has to be on.
But even changing the OptionGadgets state to #False after each one leaves them enable.
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

And it works well on Windows 11.
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB6.21] Bug? All radio buttons become on

Post by Demivec »

marcoagpinto wrote: Mon Jun 16, 2025 11:14 am
Demivec wrote: Mon Jun 16, 2025 11:09 am
The first time this function is called, a group is created and all following calls of OptionGadget() will add a gadget to this group. To finish the group, just create a gadget of another type.
IMHO this is not a big and it is according to the documentation.

Solution, create all of the OptionaGadgets in the same group first, then the TextGadgets that are near them.

Right now you are putting only one OptionGadget in each group because you follow each with a TextGadget. If there is only one OptionaGadget in a group it is will be on because one in each group has to be on.
But even changing the OptionGadgets state to #False after each one leaves them enable.
If you have an OptionGadget group with only one OptionGadget in it then which one of them in that group should be on? Since there is only one option it would always be the same one. It doesn't make since If there were to be no options selected in the group.
User avatar
Demivec
Addict
Addict
Posts: 4257
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB6.21] Bug? All radio buttons become on

Post by Demivec »

marcoagpinto wrote: Mon Jun 16, 2025 11:19 am And it works well on Windows 11.
Change the creation order of the gadget types like I suggested and see if it then works in both Windows and Ubuntu.
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 188
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: [PB6.21] Bug? All radio buttons become on

Post by moulder61 »

@marcoagpinto

This seems to work on Linux. Not sure if it will still work on Windows?

I took what Demivec said into account plus chopped your code up a bit. Probably not real programming, but it works. :P

Moulder.

Code: Select all

  Procedure GadgetFit(MARCOAGPINTO_gadget)
  
    MARCOAGPINTO_x=GadgetX(MARCOAGPINTO_gadget)
    MARCOAGPINTO_y=GadgetY(MARCOAGPINTO_gadget)
    MARCOAGPINTO_w=GadgetWidth(MARCOAGPINTO_gadget)
    MARCOAGPINTO_h=GadgetHeight(MARCOAGPINTO_gadget)
    MARCOAGPINTO_w_new=GadgetWidth(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
    MARCOAGPINTO_h_new=GadgetHeight(MARCOAGPINTO_gadget,#PB_Gadget_RequiredSize)
  
    If MARCOAGPINTO_w<>MARCOAGPINTO_w_new Or MARCOAGPINTO_h<>MARCOAGPINTO_h_new
      ResizeGadget(MARCOAGPINTO_gadget,MARCOAGPINTO_x,MARCOAGPINTO_y,MARCOAGPINTO_w_new,MARCOAGPINTO_h_new)      
    EndIf
           
  EndProcedure    
  



OpenWindow(1,10,10,800,600,"Testing",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)    
OpenWindow(2,0,0,640,480,"About",#PB_Window_WindowCentered,WindowID(1))
DisableWindow(1,#True)


  x=10
  y=10
 
    default_gadget_height_radio=21
    For i = 1 To 5
      TextGadget(i+1000,x,y,10,10,"Radio "+i)
      ;OptionGadget(i,x,y+20,default_gadget_height_radio,default_gadget_height_radio,"")

      x+GadgetWidth(i+1000)+60
       ;  GadgetFit(i)
         GadgetFit(i+1000)
    Next i
    x=20
    y=15
    For i = 1 To 5
      ;TextGadget(i+1000,x,y,10,10,"Radio "+i)
      OptionGadget(i,x,y+20,default_gadget_height_radio,default_gadget_height_radio,"")

      x+GadgetWidth(i)+50
         GadgetFit(i)
        ; GadgetFit(i+1000)
    Next i
    

  okay=#False
  Repeat
      
    event=WaitWindowEvent()
      
     
    If event=#PB_Event_CloseWindow
      okay=#True     
    EndIf      
      

  Until okay=#True

    
  ; Close the About window and activate the main window
  DisableWindow(1,#False)
  CloseWindow(2)
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

@Fred

I have fixed it in my app, but would it be possible for it to work in Windows like it does on Linux?

This way it would have been working before I compiled the code on Linux.

Thanks!
Fred
Administrator
Administrator
Posts: 18150
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by Fred »

It's not a bug because to ensure it works as a group the OptionGadget() should be created without gadget in between. That said, excluding TextGadget() which doesn't have a tabstop makes sense, even if it's not documented as is.
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

Fred wrote: Thu Jun 19, 2025 10:20 am It's not a bug because to ensure it works as a group the OptionGadget() should be created without gadget in between. That said, excluding TextGadget() which doesn't have a tabstop makes sense, even if it's not documented as is.
@Fred,

If on Windows, it had selected all the radio buttons, I would have fixed the code on Windows before compiling on Linux.

Because they would work identically.

It is always a surprise when one spends months developing code, and then he goes to Ubuntu, and it gives entirely different results.
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 188
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: [PB6.21] Bug? All radio buttons become on

Post by moulder61 »

@marcoagpinto

I'm curious to know how you fixed your app? Did you rewrite it so it's compatible with both systems or did you use CompilerIf and two sets of code, depending? Or something else?

Just a thought, how about writing it to work on Linux first? Maybe it would be less trouble doing it that way around?

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
marcoagpinto
Addict
Addict
Posts: 1039
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: [PB6.21] Bug? All radio buttons become on

Post by marcoagpinto »

moulder61 wrote: Thu Jun 19, 2025 11:13 am @marcoagpinto

I'm curious to know how you fixed your app? Did you rewrite it so it's compatible with both systems or did you use CompilerIf and two sets of code, depending? Or something else?

Just a thought, how about writing it to work on Linux first? Maybe it would be less trouble doing it that way around?

Moulder.
I fixed it on Linux by first drawing the radio buttons hidden at the same x,y.

Then, in the code, I used the command that moves the gadgets to move them to the real coordinates and showed the radio buttons one by one (move radio, show radio, add text, move radio, show radio, add text, move radio, show radio, add text, etc.)
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 188
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: [PB6.21] Bug? All radio buttons become on

Post by moulder61 »

It sounds complicated, but if you got it working, cool. 8)

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
Post Reply