Improve the ButtonGroup experience in editor? #9292
Replies: 4 comments 5 replies
-
You can use the Copy button in the resource dropdown then Paste in other locations to use a built-in resource multiple times in the same scene. This can't be done across different scenes though, unless the subscene has Editable Children enabled and you give it the built-in resource from the parent scene in the editor.
ButtonGroup is a resource, not a node. Resources don't have signals you can connect. The
The reason it works with resources instead of a child node setup is to avoid imposing a certain scene hierarchy (which has an importance when using containers). This matters because buttons that are part of a ButtonGroup aren't always right next to each other. Godot 2.x used a node-based ButtonArray system and it suffered from this limitation if I recall correctly. |
Beta Was this translation helpful? Give feedback.
-
I tried to use ButtonGroup again and hit another weird problem with it. In the case I'm using them for now, it's for a set of timescale buttons like you see in games like SimCity or Rollercoaster Tycoon: pause, play, fast-forward, super-fast-forward. I wired a ButtonGroup to all of them, set their container's ProcessMode to be Always, and thought that would be fine. Unfortunately, when I hit the Pause button, suddenly all the buttons stopped responding. After some debugging I realized that because a ButtonGroup is a Resource and not a Node, it doesn't have a To keep it as a Resource but improve its usefulness, it would need to continue receiving exceptional behaviors that make it behave like a Node (emitting signals, process mode, etc) , but not actually be a Node so it doesn't interfere with layout flow like the previous ButtonArray problem. Implementing my previous suggestions for improving the editor experience with it would also require a bunch of exceptions to the typical flow. I'm not a C++ developer, but that sounds like a maintenance nightmare to me. Overhaul ButtonGroup?Since the Node-based approach hasn't worked in the past, and the Resource-based approach has a bunch of awkward downsides as well as a future of painful exceptions, maybe I could suggest something similar to what HTML does? In HTML, button tags that are In Godot, that might be best implemented as a string property on BaseButton, called something like "Group Name". If that property is defined, then the button goes into radio-button mode. When pressed, any . On BaseButton, make the ButtonGroup attribute a string. If the string is defined, then it goes into radio-button mode. This is where I especially can't speak to the implementation details, but in C# language, I'd say you'd want a static dictionary on the As for signals, I don't know what would be more in line with what the rest of the engine does: having a signal be emitted from the static BaseButton class (like Since now I'm suggesting to change the whole resource, maybe this topic should be moved to a different category? But either way, hopefully some of that was good food for thought! |
Beta Was this translation helpful? Give feedback.
-
First thing this type of modification is compat breaking and thus can't be done lightly (no chance until Godot5 I think here) |
Beta Was this translation helpful? Give feedback.
-
One way you can easily assign buttons to the same group is by selecting the buttons and then create the ButtonGroup: |
Beta Was this translation helpful? Give feedback.
-
Hello, relative Godot newbie here. Having made a radio button list for the first time today, I was somewhat annoyed with the experience of using
ButtonGroup
. The examples I can find all suggest instantiating and connecting signals in code, but this feels like something that would be relatively easy to improve in the editor.As it is, the "Button Group" field is accessible in the editor and lets you make a new
ButtonGroup
. But the only way to assign other buttons to the same group is to save it as a resource (making an unnecessary Resource file, since there's nothing customizeable about aButtonGroup
) or to duplicate the button. Or edit the scene file I guess.Once multiple buttons are assigned to the same group, there's no way to connect the
pressed
signal while in the editor-- right-clicking theButtonGroup
and choosing Edit lets you select specifically the group, but then choosing the Node tab just shows the blank "Select a single node to edit its signals and groups" readout. I think this is because it's a Resource and not a Node? But I'm not sure.I feel like this is so close to working in the editor. The alternative of having to assign all the buttons to groups, then in my scene's
_Ready()
function give them a new ephemeral ButtonGroup, then hook up the signal, is pretty lame.If an editor UI solution isn't the best here, perhaps it would be a bit heavy-handed, but maybe a new Control-type node could be made that wraps multiple Button-type nodes, and can emit a
.pressed()
signal in the same wayButtonGroup
does?Beta Was this translation helpful? Give feedback.
All reactions