+5 votes

Hate to ask such a stupid question but I've spent too long searching for a way to make this work. They're checkboxes, right? There is no magical "ButtonGroup", adding a group to each checkbox does nothing, putting them in a container does nothing.
Is there a way to make radio buttons in Godot 3.0? TIA

in Engine by (20 points)

I figured it out (I actually had a working example in the project I was working on...so dumb xD).
Create a new CheckBox and it has a "Group" property. Click the arrow, create a new ButtonGroup and name it. Then click the arrow again and Copy. Make another checkbox, click arrow --> Paste. Radio buttons.

2 Answers

+10 votes
Best answer

This is an older question, but the only answer doesn't seem to be up-to-date.

If you create a CheckBox node, under the BaseButton section in the inspector you can create/define a Group (button group) for it. Copy this group for every radio box in the same group.

This is all you need to do, now the buttons act as radio buttons.

by (1,607 points)
selected by

even normal button works, if toogle mode checked, tested in godot 3.1.1

+1 vote

I don't know if there is an official way to do this, but i've done this way:
First, i create a new scene with a CheckBox node, which i call RadioButton, and i save it as RadioButton.tscn. I add to it a script with this content:

extends CheckBox

func is_radio():

func _ready():

func _process(delta):

func _on_RadioButton_toggled(button_pressed):
   if button_pressed:
        for child in get_parent().get_children():
            if child.has_method("is_radio"):
                child.pressed = false
                pressed = true
                pressed = true

Be sure you connect the toggled() signal to _on_RadioButton_toggled() function.
Then i instantiate in the scene i want the radio buttons as many as i want.

Note: I think this would work better if we use groups, but i've been using this way with no trouble at all.

by (3,503 points)

I was so sure there would be a way to just have the checkboxes treated as radio buttons, but this is an excellent workaround. Thanks!

You are welcome! Could you select my answer as correct then? So others can see it works.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.