uifigure+uitree, multiple selected nodes
22 views (last 30 days)
Show older comments
Hello,
Does anybody know a (undocumented) workaround to have multiple nodes selected in a uitree with checkboxes? I like to distinguish between checked and selected items.
If the uitree component is used without checkboxes it is possible. I am wondering why this is not implemented (yet)...
hF = uifigure();
hT = uitree(hF,'checkbox');
hO1 = uitreenode(Parent=hT, Text='object1');
hO2 = uitreenode(Parent=hT, Text='object2');
hO3 = uitreenode(Parent=hT, Text='object3');
hO4 = uitreenode(Parent=hT, Text='object4');
hT.CheckedNodes = [hO1, hO2];
hT.SelectedNodes = [hO3, hO4];
%Error using matlab.ui.container.internal.model.TreeComponent/set.SelectedNodes (line 161)
%'SelectedNodes' must be an empty array or a 1-by-1 TreeNode object that is a child in the CheckBoxTree.
Thanks in advance,
Martin
0 Comments
Accepted Answer
dpb
on 19 Aug 2025 at 14:11
Edited: dpb
on 19 Aug 2025 at 15:37
Does not appear to be possible; looking at the undocumented/hidden properties with <Yair Altman getundoc> reveals that the 'MultiSelect' property doesn't even exist, rather than simply not made public. Given this, it would not appear possible to modify the current behavior using the 'Style','Checkbox' option.
One could use independent check boxes and manipulate them with a callback to set their state(s) based on the properties of a standard tree with 'MultiSelect','on'. I dunno about how much effort it would be to also draw in a background to match, though.
Another option could be to use an uitable with a checkbox column.
2 Comments
dpb
on 19 Aug 2025 at 14:51
Submit this to Mathworks as an official support request for enhancement at <Product Support Page>; mayhaps an official response as to there being some reason the option isn't available with the checkbox style that isn't apparent superficially.
More Answers (0)
See Also
Categories
Find more on Develop uifigure-Based Apps 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!