How can I control the stacking order of objects in appdesigner?
39 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kevin J. Delaney
el 4 de En. de 2018
Respondida: Adam Danz
el 17 de Mzo. de 2023
How can I control the stacking order of objects in appdesigner? It seems to be determined by the order in which the panels or axes are created. What if I want an object created later to slide underneath earlier objects?
0 comentarios
Respuesta aceptada
Sean de Wolski
el 4 de En. de 2018
You can control the order of the 'Children' of a graphics object directly:
fig = uifigure;
panel1 = uipanel(fig, 'BackgroundColor', 'b');
panel2 = uipanel(fig, 'BackgroundColor', 'r');
fig.Children = flip(fig.Children)
6 comentarios
Sean de Wolski
el 8 de Feb. de 2018
I was just copying what you had to show that it works, they were adjacent in the question so assumed it was all in your startup. I wouldn't recommend calling uipanel in startup!
It's definitely a fair enhancement request to have them be adjustable in the component browser on the right.
paul harder
el 28 de Ag. de 2020
Yes, intuitively I should be able to drag panels up and down the component browser to order the stacking. It seems like the stack order is tied to the order of creation, which is super inflexible.
Más respuestas (3)
Wouter
el 14 de Feb. de 2018
You could also keep a list of handles; e.g. in the variable background and than move all of these to the background.
hfig = uifigure; % create figure
hax = uiaxes(hfig); % create axis
foreground = plot(hax,rand(1,100),'r'); % create red line
hold(hax,'on');
for ind = 1:10
% this moves the foreground plot to the background...
background(ind) = plot(hax,rand(1,100),'k'); % create 10 ack lines (on top of red line)
end
% move the background lines to the background!
ch = get(hax,'children'); % get all plots from hax
[~,neworder] = sort(ismember(ch,background)); % reorder the handles to move the background lines to the background
set(hax,'children',ch(neworder)); % set the new order of all lines
0 comentarios
Ver también
Categorías
Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!