Enable on/off take effect only after window resize

I use this code to disable all ui components. All workes eccept for one table. Putting a Breakpoint at the end of the function and checkig the Enable attribute of that table showes that it is 'off'. When I resize the window the display updates and the table shows grayed.
The same thing happens after I enable all the ui components. I tried to refresh the figure, I also tried to call figure(), none worked. Any idea what might cause the problem and how can I fix it?
function DisableApp(app, hExceptFor)
Child = findall(app.MyApp);
N = length(Child);
for i= 1 : N
if isprop(Child(i),'Enable')
set(Child(i), 'Enable', 'off');
end
end
if nargin == 2
M = length(hExceptFor);
for i= 1 : M
if isprop(hExceptFor(i),'Enable')
set(hExceptFor(i), 'Enable', 'on');
end
end
end
end

 採用された回答

Adam Danz
Adam Danz 2021 年 4 月 25 日
編集済み: Adam Danz 2021 年 4 月 25 日

0 投票

First, this is not the best approach to disabling all components. Two alternatives that are much simpler and offer easier control are,
  • Create a uipanel that contains all of the app components you want to toggle on/off. Then, just toggle the uipanel's enable property.
  • Use a uiprogressbar with the indeterminate option to disable the entire app until progress is resummed programmatically or manually.
About the problem with the uitable, it's not clear what you're seeing vs what you expect to happen. Maybe a screenshot would help. If you want the table to completely disappear, set its Visible property rather than its Enable property.

4 件のコメント

Adam Danz
Adam Danz 2021 年 4 月 25 日
Michal Mika's answer moved here as a comment
Thank you for your answer. This is a screenshot of part of the application. The Beat/Select table is not grayed as it should after I set the Enable to 'off' like all other tables and components. when I resize the window the display updates and problem is fixed but this is not an appropriate solusion for users. This is a very large application with many tabs, tables and charts. all coponents work well eccept for this table.
Adam Danz
Adam Danz 2021 年 4 月 25 日
編集済み: Adam Danz 2021 年 4 月 25 日
I see, thanks for the image. Also, thanks for including your Matlab release info.
If you have access to Matlab online which uses r2021 you could test if it's a bug that was fixed.
This could also be a quirk that results from how you're looping through and making changes to a bunch of handles in a short amount of time. As I recommended in my answer, these two sections below could all be uipanels that contain those objects (I see I missed some components but you get the point). Then you would just need to turn off/on the 2 panels.
Another thing you could try with your current method is to include a drawnow at the end of DisableApp.
Mika
Mika 2021 年 4 月 25 日
Thank you. I'll definatly try using panels and let you know how it worked
Mika
Mika 2021 年 4 月 26 日
Looks like it works. Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

リリース

R2019b

質問済み:

2021 年 4 月 25 日

コメント済み:

2021 年 4 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by