RadioButtonGroup toggle Off Button

Hello,

earlyer i’ve feel the need to have the ability with RadioButtonGroup to remove the toggle of a Button and since i couldn’t find a way i’ve added some line on the core, if someone can review them it would be nice :slight_smile:

i’m pretty new to this… i didn’t managed to build the source and test this out so i don’t know if it work but the idea is there so if someone can manage to make this work it will be a lot of help for me and if it could be added to the core that’s even better :smiley:

[java]
/**
* Sets the current selected Radio Button to the Button associated with the provided index
* @param index
*/
public void setSelected(int index) {
if (this.selectedIndex != index && index != -1) {
if (index >= 0 && index < radioButtons.size()) {
Button rb = radioButtons.get(index);
this.selected = rb;
this.selectedIndex = index;
for (Button rb2 : radioButtons) {
if (rb2 != this.selected)
rb2.setIsToggled(false);
else
rb2.setIsToggled(true);
}
onSelect(selectedIndex, rb);
} else if (index == -1){
this.selected = null;
this.selectedIndex = -1;
for (Button rb2 : radioButtons) {
rb2.setIsToggled(false);
}
}
}
}

    /**
     * Sets the current selected Radio Button to the Button instance provided
     * @param button
     */
    public void setSelected(Button button) {
        if (this.selected != button &amp;&amp; button != null) {
            this.selected = button;
            this.selectedIndex = radioButtons.indexOf(button);
            for (Button rb : radioButtons) {
                if (rb != this.selected) {
                    if (rb.getIsToggled()){
                        rb.setIsToggled(false);
                    } else {
                        rb.setIsToggled(true);
                    }
                }
            }
            onSelect(selectedIndex, button);
        } else if (button  == null){
            this.selected = null;
            this.selectedIndex = -1;
            for (Button rb2 : radioButtons) {
                rb2.setIsToggled(false);
            }
        }
    } [/java] 

Thx.

I can’t Edit my previous post so sorry in advance for the double…

Wanted to say is it possible to have a function who could return the number of added button, it can be realy handy when it come to get a button position inside the group.

@kobRoah said: I can't Edit my previous post so sorry in advance for the double...

Wanted to say is it possible to have a function who could return the number of added button, it can be realy handy when it come to get a button position inside the group.

Let me see what I can do about getting these in there.

To clarify the first, you would like the option to untoggle all radio buttons, correct? And if so…

Via code?
Via button click?
Or both?

Hey :smiley:
You got it, on code that’s enought ^^