uifigure+uitree, multiple selected nodes
22 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
dpb
2025 年 8 月 19 日 14:11
編集済み: dpb
2025 年 8 月 19 日 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 件のコメント
dpb
2025 年 8 月 19 日 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.
その他の回答 (0 件)
参考
カテゴリ
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!