uifigure+uitree, multiple selected nodes
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Martin
el 19 de Ag. de 2025 a las 11:03
Comentada: Martin
el 20 de Ag. de 2025 a las 7:52
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 comentarios
Respuesta aceptada
dpb
el 19 de Ag. de 2025 a las 14:11
Editada: dpb
el 19 de Ag. de 2025 a las 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 comentarios
dpb
el 19 de Ag. de 2025 a las 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.
Más respuestas (0)
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!