This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

uistack

Reorder visual stacking of UI components

Syntax

uistack(comp)
uistack(comp,moveto)
uistack(comp,moveto,step)

Description

example

uistack(comp) 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.

example

uistack(comp,moveto) moves the UI component to another position in the stack. For example, uistack(f,'top') moves component f to the top of the current stack.

example

uistack(comp,moveto,step) specifies the number of levels to move the UI component up or down. For example, uistack(c,'up',2) moves c up two levels in the current stack.

Examples

collapse all

Create a figure with five panels and reorder the panel stacking positions.

Create five panels, specifying different titles and background colors for each using the 'Title' and 'BackgroundColor' name-value pair arguments. Next, specify the position of each panel by setting its Position property.

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];

Then, 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)

Next, create a two-element vector containing panels a and c. Then, reorder the panels by passing the vector into the uistack function. Panels a and c both shift up one level in the stack, relative to their previous positions.

vpanel = [a c];
uistack(vpanel);

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.

uistack(t4,'bottom');

Then move the Survey Questions tab down two levels.

uistack(t1,'down',2);

Input Arguments

collapse all

UI component to reorder, specified as a single object or vector of objects, such as Figure, Panel, ButtonGroup, UIControl, Axes, or Tab objects. Use this argument to specify the UI components you wish to reorder within the current stack.

If 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 elements.

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 ValueDescription
'up'Up step positions (one position by default).
'down'Down step positions (one position by default).
'top'To the top of the current stack.
'bottom'To the bottom of the current stack.

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.

Compatibility Considerations

expand all

Behavior changed in R2014b

Introduced before R2006a