How can I find an uifigure?
77 次查看(过去 30 天)
显示 更早的评论
I am mixing some old GUIs designed with GUIDE with uifigures, so I can use the uitree object (and some others).
However, when I try to establish communication between some functions in my GUIs (need to click on an ax and then assign some value from a tree node and insert into a table) I cannot find the uifigure - neither using "findobj ('Type', 'figure')" nor using "findall (groot)". Before I started this design I did not even consider this possibility, thought it would be something quite simple - which it probably is but I cannot get past this point.
Would really appreciate any answer or a possible solution to this issue.
采纳的回答
Adam Danz
2020-1-26
编辑:Adam Danz
2020-1-27
You can find the uifigure handle using findall() but it's not recommended to merely find handles to all figures because it's quite likely that at some point other figures will exist other than your GUI.
To find the handle to your GUI figure, add a long, descriptive, unique name to the tag property of your GUI. Then specify that unique tag name when searching for the GUI handle.
uif = uifigure('Tag','MyUniqueTag'); % a demo ui-figure with a unique tag name
h = findall(0,'Type','figure','tag','MyUniqueTag') % Get the handle.
To search for all figures (hidden or not)
h = findall(0,'Type','figure');
0 个评论
更多回答(2 个)
Walter Roberson
2020-1-26
If you create the uifigure with HandleVisibility, 'on', then you can
findobj(groot, 'type', 'figure')
otherwise you need findall() because the handle visibility for uifigure defaults to 'off'
0 个评论
Clovis Bonavides
2020-1-28
3 个评论
Adam Danz
2020-1-28
编辑:Adam Danz
2020-1-28
Clovis Bonavides's answer moved here as a comment
Adam, you are absolutely correct. It DOES work in vers 2019.b, which I just got loaded.
In vers 2018b it doesn't work as the uifigure's handle visibility is "hardwired" to "OFF" and cannot be changed through the uifigure generation code.
Thanks!
Adam Danz
2020-1-28
On the right hand column of this page you can see the Product and Release fields where you entered r2019b. This is very helpful info and most people don't fill it out (so, thank you!).
BTW, I just tested the lines in my comment above in r2018b and it also works there, too. Maybe something was copied wrong when you were trying it out.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!