-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Comments
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? |
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 |
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 |
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. |
Closes #3478 Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
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?
The text was updated successfully, but these errors were encountered: