Get access to all buttongroups in my app
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Henk-Jan Ramaker
le 7 Avr 2023
Commenté : Henk-Jan Ramaker
le 14 Avr 2023
I have created an app that can be used as a questionnaire. There are several tabs. On each tab, there is a buttongroup with radiobuttons. E.g. for the question "what is your sex" there are two answers possible: male or female. The initial answer is "female" in this case. The user can navigate to the next tab where there is another question and so on. When the user reaches the end, I want to reset the questionnaire. So, each radiobuttongroup should be initialized again. If somebody selected "male" it shoud be reset to "female" again,
How can I cycle through all possible buttongroups inside startFcn to record the initial state? I cannot get findall or findobj to work for this purpose, it gives me nothing but an empty graphics holder. To make it clear: I don't want to use the hard wired names I gave to the ButtonGroups, I want them to be found & selected programatically. And how can I use the initial states collected during the startFcn in order to initialize all the buttongroups again when a reset is requested?
1 commentaire
Image Analyst
le 7 Avr 2023
You forgot to attach your .mlapp file.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Réponse acceptée
Vinayak Choyyan
le 10 Avr 2023
Hi Henk-Jan Ramaker,
As per my understanding, you are trying to reset some radio button groups. You would like to do this programmatically and not by calling them by name.
Please find the attached MATLAB app file. In this example file, I have added a private property named ‘defaultButtonGroup’. This variable is used to store the default values of all radio button groups. Within the ‘startupFcn’, we save all the initial values. Then when the ‘Reset’ button is clicked, within the ‘ResetButtonPushed’ callback function, we reassign the default values back to all the radio groups.
As you have not posted your code, I have taken to liberty of making a simple app example. Please modify the example as per your use case.
Please feel free to check out the following link https://www.mathworks.com/help/matlab/ref/matlab.ui.container.buttongroup-properties.html#bujxo9x-79-SelectedObject to read more about the ‘SelectedObject’ property of ‘ButtonGroup’.
I hope this resolves he issue you are facing.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dialog Boxes dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!