Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unpressing all buttons in a ButtonGroup #6722

Closed
TheSecondReal0 opened this issue Apr 20, 2023 · 1 comment · Fixed by godotengine/godot#76279
Closed

Allow unpressing all buttons in a ButtonGroup #6722

TheSecondReal0 opened this issue Apr 20, 2023 · 1 comment · Fixed by godotengine/godot#76279
Milestone

Comments

@TheSecondReal0
Copy link

TheSecondReal0 commented Apr 20, 2023

Describe the project you are working on

User interface

Describe the problem or limitation you are having in your project

I consistently find myself wanting to have a group of buttons where only one can be pressed at a time but you can also unpress all of them.

For instance, a map editor. When you press a button to select what object to place, you want the other buttons to unpress. Extremely easy with button groups. But what if you want to press that same button again to have no object selected? Currently this behavior is impossible without creating your own ButtonGroup-like system.

Example of map editor:

map_editor_example.mp4

You would hit the same road block developing a UI with categories and dropdowns like this:

category_example.mp4

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Solution 1: Add a toggle to ButtonGroup for whether or not all buttons can become unpressed
Solution 2: Create a child class of ButtonGroup that allows all buttons to become unpressed

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Current behavior:

normal_buttongroup.mp4

Proposed behavior:

unpressable_buttongroup.mp4

Possible feature UI (allow_unpress disabled by default to maintain compatibility):
image

PR with implementation:
godotengine/godot#76279

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked around, but the workaround is creating an entire system yourself that copies the behavior of ButtonGroup with one minor tweak. While it's not that hard, it seems unnecessary given the engine already has a system that's 99% of the way there.

Is there a reason why this should be core and not an add-on in the asset library?

This seems like a useful enough feature to be part of the engine and it can be added without breaking compatibility. It would resolve a pain point that I'm sure many developers have run into and would make it even easier to create responsive UIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants