Reorder visual stacking of UI components
Use this function only with GUIDE, or with apps created using the
uistack( shifts the specified component
up one level within the front-to-back visual stacking order of UI components. If
comp is specified as a vector of UI components, each component in the
vector gets shifted up by one.
Create five overlapping panels with different titles and background colors.
f = figure; a = uipanel(f,'Title','A','BackgroundColor','white'); b = uipanel(f,'Title','B','BackgroundColor','cyan'); c = uipanel(f,'Title','C','BackgroundColor','green'); d = uipanel(f,'Title','D','BackgroundColor','yellow'); e = uipanel(f,'Title','E','BackgroundColor','magenta'); a.Position = [0.35 0.50 0.30 0.35]; b.Position = [0.18 0.40 0.30 0.35]; c.Position = [0.08 0.21 0.30 0.35]; d.Position = [0.25 0.33 0.32 0.35]; e.Position = [0.30 0.27 0.30 0.35];
List the order of children in the figure.
figChildren = f.Children
figChildren = 5×1 Panel array: Panel (E) Panel (D) Panel (C) Panel (B) Panel (A)
Reorder the panels by shifting
c up one
level in the stack, relative to their previous positions.
comp = [a c]; uistack(comp);
List the children again. Changing the stacking order of the panels also changes the order of the children in the figure.
figChildren = f.Children
figChildren = 5×1 Panel array: Panel (E) Panel (C) Panel (D) Panel (A) Panel (B)
Create a figure that contains a tab group with five tabs.
f = figure; tg = uitabgroup(f,'Position',[0.05 0.05 0.85 0.85]); t1 = uitab('Title','Survey Questions'); t2 = uitab('Title','Demographic'); t3 = uitab('Title','Participant List'); t4 = uitab('Title','Raw Data'); t5 = uitab('Title','Plot');
Move the Raw Data tab to the bottom of the stack.
Move the Survey Questions tab down two levels.
comp— UI component
UI component to reorder, specified as a single object or vector of objects, such as
objects. Use this argument to specify the UI components you wish to reorder within the
comp is specified as a vector of UI components, each
component in the vector must share the same parent and the vector must be a subset of
the children of the parent container. For example, if a figure has six child UI
components, the vector
comp can have no more than five
Location to move a UI component, specified as one of the values in the following table. Use this argument to specify the stack position you want a UI component to move to.
|Move To Value||Description|
|To the top of the current stack.|
|To the bottom of the current stack.|
step— Number of levels to shift
Number of levels to shift a UI component up or down in a stack, specified as a positive integer.
If you specify a step number that is greater than the number of stack levels available to move, then the UI component will move to the top or bottom of the stack. For example, if you have five stack levels and you specify a component to move down six steps, that component will move to the bottom of the stack.
Behavior changed in R2014b
In previous releases, the order of components listed in the
property matched the order in which they were created. However, this order did not
necessarily match the visual stacking order of the components on the screen. To provide more
consistent behavior, starting in R2014b, the order of components listed in the
Children property matches the stacking order of child components on the
screen. For more information about how the stacking behavior of UI components has changed
and how to update your code, see Why Are Some Components Missing or Partially Obscured?