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

Scripting: Dialog radio buttons #3478

Closed
eishiya opened this issue Sep 24, 2022 · 5 comments · Fixed by #4107
Closed

Scripting: Dialog radio buttons #3478

eishiya opened this issue Sep 24, 2022 · 5 comments · Fixed by #4107
Labels
feature It's a feature, not a bug.

Comments

@eishiya
Copy link
Contributor

eishiya commented Sep 24, 2022

When building Dialogs, it's sometimes useful to have radio buttons. Their functionality can be achieved script-side with checkboxes, or they can be replaced with combo boxes (dropdowns), so this isn't an important feature, but it would be neat.

Qt Dialogs allow QRadioButtons and QButtonGroups, but this functionality is not currently exposed to the scripting API.
Relevant Qt docs: https://doc.qt.io/qt-5/qradiobutton.html

The challenge with radio buttons is that they derive their usefulness from belonging to a group with other radio buttons, and only one can be selected at a time. Qt considers all QRadioButtons that have the same parent to be part of the same group, but since the Dialog API doesn't give you direct control over the parent widgets and adds columns and rows automatically, this can get confusing. Perhaps rather than exposing QRadioButtons directly, the Dialog API could support only something like RadioButtonGroup that behaves a lot like a QComboBox (value changed signals, a single tooltip for the whole thing, a constructor that takes all the labels at once, etc), but which consists of a QButtonGroup and a bunch of QRadioButtons under the hood?

@eishiya eishiya added the feature It's a feature, not a bug. label Sep 24, 2022
@bjorn
Copy link
Member

bjorn commented Sep 27, 2022

I see Aseprite supports radio buttons, but how does it put them in groups?

Maybe it would make sense to simply automatically group any consecutively added radio buttons?

@solerante
Copy link

When building Dialogs, it's sometimes useful to have radio buttons. Their functionality can be achieved script-side with checkboxes, or they can be replaced with combo boxes (dropdowns)

It's already possible to create a dropdown selection dialog by script?

@eishiya
Copy link
Contributor Author

eishiya commented Nov 20, 2022

It's already possible to create a dropdown selection dialog by script?

Yes, though they're called ComboBoxes: https://www.mapeditor.org/docs/scripting/classes/Dialog.html#addComboBox

@dogboydog
Copy link
Contributor

I'll pick this up. I'm thinking you'll just provide a list of all the radio button labels and I'll figure out how to respond to the selection change signals and provide an example

@eishiya
Copy link
Contributor Author

eishiya commented Nov 27, 2024

I think handling it similarly to how ComboBoxes are handled would be good: treat each radio button group as a single widget, provide a method to add items to this group, provide signals for the selected item changing, and getters/setters of the current item. It'll probably be more complex under the hood since it's not just a wrapper for single Qt widget, but I think interacting with it just like with a combobox would be pretty simple for script authors.

bjorn added a commit that referenced this issue Nov 29, 2024
Closes #3478

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants