MATLAB Creating Graphical User Interfaces

(ff) #1

app.UIFigure.AutoResizeChildren = 'off';


To completely disable resizing, set the Resize property of the figure to 'off'.


Customizing Resize Behavior Using a SizeChangedFcn


Callback


If the automatic resize behavior is not the behavior that you want, disable the
AutoResizeChildren property and write a SizeChangedFcn callback for the
container. In this callback, you write code to adjust the Position property of the child
components. The callback executes when the size of the container changes.


For example, a SizeChangedFcn might contain code that keeps the width of an edit field
at one quarter of the width of the figure.


figwidth = app.UIFigure.Position(3);
app.EditField.Position(3) = .25 * figwidth;


NoteStarting in R2017a, you must disable the AutoResizeChildren property to allow
the SizeChangedFcn callback to execute. For more information, see “App Designer:
Disable automatic resize behavior when writing SizeChangedFcn callbacks”.


See Also


UI Figure


More About



  • “Lay Out Apps in App Designer” on page 16-2

  • “Write Callbacks in App Designer” on page 17-18

  • “Apps with Auto-Reflow” on page 16-19


See Also
Free download pdf