Is there an easier way to disable all the buttons in matlab app designer?
Show older comments
I wanted to know if there is an easier way to disable or enable all the buttons without calling each one separately. I was hoping to be able to press a start button which would then enable all the buttons in the app.
app.Button_1.Enable = "off";
app.Button_2.Enable = "off";
app.Button_3.Enable = "off";
app.Button_4.Enable = "off";
app.Button_5.Enable = "off";
app.Button_6.Enable = "off";
app.Button_7.Enable = "off";
app.Button_8.Enable = "off";
app.Button_9.Enable = "off";
Answers (1)
h= findobj(app.UIFigure,'Type','uibutton');
set(h,'Enable','off')
4 Comments
Matt J
on 3 Jun 2022
@Gert Persson's comment moved here:
Nice solution Matt!
So if I want to disable all buttons in window1, while window2 is open, this works.
But going back (and closing window2) to window1, I only want to enable the buttons that where enabled from the start.
Is there a way to sort out which buttons have 'Enable' 'on' and/or 'off'?
You can save the Enable states to a temporary variable,
h= findobj(app.UIFigure,'Type','uibutton');
saved_states={h.Enable}; %keep this somewhere
set(h,'Enable','off')
then restore them later with,
[h.Enable]=deal(saved_states{:});
Matt J
on 3 Jun 2022
@Gert Persson's comment moved here:
Yes, this will work fine for me!
Thanks a lot for your help Matt!
Matt J
on 3 Jun 2022
You're welcome, but please Accept-click the answer to indicate that it helped.
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!