GUI creating multiple objects with the same Tag

1 次查看(过去 30 天)
I have a GUI created with GUIDE named WGE_GUI and with the tag WGE_GUIh. When I run the GUI, if I insert the code
h = findobj('Tag','WGE_GUIh')
right after the GUI is made visible, then h is a 1x1 with Class of matlab.ui.Figure.
However, I have a pushbutton that when clicked runs the same findobj function as above and it returns the following:
h =
3x1 Figure array:
Figure (WGE_GUIh)
Figure (WGE_GUIh)
Figure (WGE_GUIh)
All the Figures in h seem to have the same properties, but I can't determine why there are multiple figures with the same tag. All of their FileNames (e.g. h(1).FileName) are identical and point to the GUI .fig file on my hard drive.
I'm not really sure what I'm looking for when I'm debugging. I have other buttons that use the findobj function, as well as setappdata and getappdata to pass variables between GUIs, but I get this behavior even if those aren't used. Any help would be appreciated!

回答(1 个)

Walter Roberson
Walter Roberson 2018-2-5
Some of the objects might have HandleVisibility set to 'callback'; see https://www.mathworks.com/help/matlab/creating_plots/preventing-access-to-figures-and-axes.html
At the command line, try findall() instead of findobj()

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by