フィルターのクリア

'AutoResizeChildren' App designer warning

61 ビュー (過去 30 日間)
Eric Pulling
Eric Pulling 2017 年 9 月 12 日
コメント済み: ARHUM AHMAD 2022 年 4 月 11 日
This occurred in an area of the code that was grayed out (unchangeable and created by the App Designer). Thoughts on what this could mean?
Warning: 'SizeChangedFcn' callback will not execute while 'AutoResizeChildren' is set to 'on'. > In LaunchAcoustics/createComponents (line 982) In LaunchAcoustics (line 1098) In FSIAcousticsApp/startApp (line 90) In FSIAcousticsApp (line 48) In appinstall.internal.runapp>execute (line 78) In appinstall.internal.runapp>runapp13a (line 57) In appinstall.internal.runapp>runcorrectversion (line 36) In appinstall.internal.runapp (line 18)

採用された回答

Alice
Alice 2017 年 9 月 13 日
In short:
The warning is displayed because you have both the "Resize components when app is resized" option checked and have written a SizeChangedFcn callback on a container. These two things are mutually exclusive, you must choose one or the other. If you have both, the SizeChangedFcn callback will be ignored.
More details...
AutoResizeChildren is a property that corresponds to the "Resize components when app is resized" checkbox in the "uifigure properties" panel (to see this panel, click on the edge of the uifigure, this panel is by default in the lower right side).
  • Code-wise, when this checkbox is checked, the AutoResizeChildren is set to 'on' on the uifigure and on all the containers inside that app.
  • Behavior-wise, when the checkbox is checked, once you run the app and then resize it, components inside your app (and inside all the containers) will be resized based on some heuristics.
Now, containers also have a SizeChangedFcn property that allows you to specify how components should be resized when the container itself is resized.
You should either choose to have the components resized based on the heuristics (i.e. check that checkbox), or write SizeChangedFcn callbacks on the containers, but not both. If you have written a SizeChangedFcn function on any container inside that app or on the uifigure, and checked the AutoResizeChildren option, the SizeChangedFcn function(s) will be ignored and components will be resized based on the heuristics. The warning tells you that the SizeChangedFcn will be ignored.
If you want the SizeChangedFcn callback(s) to work, you must uncheck the "Resize components when app is resized" checkbox.
Note: Even if you have removed the content of a SizeChangedFcn callback, the callback is still defined. If you want to use AutoResizeChildren behavior, you must remove the SizeChangedFcn callback altogether (right click, delete the callback).
  2 件のコメント
zeytun
zeytun 2021 年 1 月 17 日
編集済み: zeytun 2021 年 1 月 17 日
Alice, thank you for this detailed answer. I have the same problem: I accidentally clicked on "Add SizeChangedFcn Callback" and now cannot get rid of both the warning message in Command Window, and the lines in the code. The note above in your answer says:
Note: Even if you have removed the content of a SizeChangedFcn callback, the callback is still defined. If you want to use AutoResizeChildren behavior, you must remove the SizeChangedFcn callback altogether (right click, delete the callback).
Unfortunately, I cannot find (or maybe see) the callback to right click on it and delete.
zeytun
zeytun 2021 年 1 月 18 日
Okay, this is solved. I was looking for the callback in the "Component Browser", instead of the right location, which is the "Code Browser." Thanks again!

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

その他の回答 (1 件)

John
John 2020 年 1 月 30 日
How to remove the SizeChangedFcn?
  1 件のコメント
ARHUM AHMAD
ARHUM AHMAD 2022 年 4 月 11 日
check in this section you will able to figure it out.

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

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by