How can I find an uifigure?
Show older comments
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.
6 Comments
Allen
on 25 Jan 2020
I am able to create a figure using uifigure and then find the handle using findall(groot) using R2019b. Have you tried assigning a name to the figure during creation? If not, it might be worth a try to see if you are not locating it simply because it is hard to identify amoung a list of Figures when using findall.
uifigure('Name','YourFigureName')
Clovis Bonavides
on 26 Jan 2020
Adam Danz
on 26 Jan 2020
Have you tried findall without the tag? That should work with uifigures / appdesigner.
Walter Roberson
on 26 Jan 2020
I had no problem using
H = uifigure('handlevisibility', 'on')
when I tested.
Clovis Bonavides
on 26 Jan 2020
In r2019b the handlevisibility property of uifigures can only be set to off.
When it's set to "on" you get a "functionality not supported" error. Maybe that will change in 2020a.
Accepted Answer
More Answers (2)
Walter Roberson
on 26 Jan 2020
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'
Clovis Bonavides
on 28 Jan 2020
0 votes
3 Comments
My answer absolutely works in r2019b (the release you're using).
% Create a UIFigure
uif = uifigure('Name','ThisWorks!');
% Find handles to all figures
h = findall(0,'Type','figure')
Result
h =
Figure (ThisWorks!) with properties:
Number: []
Name: 'ThisWorks!'
Color: [0.9400 0.9400 0.9400]
Position: [508 656 583 437]
Units: 'pixels'
Show all properties
If it doesn't work for you then something else is wrong.
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
on 28 Jan 2020
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.
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!