uifigure+uitree, multiple selected nodes

22 ビュー (過去 30 日間)
Martin
Martin 2025 年 8 月 19 日 11:03
コメント済み: Martin 2025 年 8 月 20 日 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

採用された回答

dpb
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
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.
Martin
Martin 2025 年 8 月 20 日 7:52
@dpb thanks for your time to react. I will take your alternative suggestions in mind and will send a service request (feature request) to Mathworks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by