Figure createfcn in app designer

9 次查看(过去 30 天)
Adee
Adee 2021-12-2
回答: Adee 2021-12-2
I have an app that always creates an empty figure when I load it into appdesigner. It is quite annoying.
I realized after some debugging that it is caused by the createfcn property of the top figure, which has been set to a function that caused the window to open. When I deleted the function I got an error. The biggest problem is, I could not find any way to access the createfcn field from appdesigner.
The value of createfcn seems to have resulted from setting the default figure createfcn to a non-empty value when the app was created... After that point, it is saved in the app with no apparent way to change it.
To reproduce this problem, do something like
set(groot, 'defaultfigurecreatefcn', 'disp Hello')
and then create an app in appdesigner.
I suspect the same issue can happen with any of the default settings, especially createfcn's of various objects, that are not exposed in appdesigner.
I have an awkward workaround that I'll post as an answer, but any other suggestions are welcome.

回答(1 个)

Adee
Adee 2021-12-2
An awkward way to remove the figure createfcn:
  1. Place a breakpoint in %MATLABPATH%\toolbox\matlab\appdesigner\appdesigner\+appdesigner\+internal\+serialization\FileReader.m, after the line "appData = load(tempFileLocation);" (That is the line that causes the createfcn to run).
  2. Load the app into appdesigner
  3. When the breakpoint is hit, Enter appData.components.UIFigure.CreateFcn='' ;
  4. Continue with loading the app
  5. Use "Save as" to save the app with another name
The app with the new name should have no figure createfcn.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by