フィルターのクリア

How to disable uitreenode?

23 ビュー (過去 30 日間)
Elando
Elando 2017 年 3 月 14 日
回答済み: Lior de Marcas 2021 年 11 月 18 日
I made a uitree in a GUI and I'd like to disable this tree because I want it only to show the structure and not to surf through it.
Is it possible to disable the uitreenode and make them not selectable? When the user press on a node I don't want to make it selected.
Thank you

回答 (1 件)

Lior de Marcas
Lior de Marcas 2021 年 11 月 18 日
I guess the easiest way is to define it in the SelectionChangedFcn of the uitree:
fig = uifigure;
t = uitree(fig);
parent = uitreenode(t,'Text',"parent");
child = uitreenode(parent,'Text',"child");
expand(t)
t.SelectionChangedFcn = @(treeobj,~) ParentUnselectible(treeobj)
function ParentUnselectible(treeobj)
if strcmp(treeobj.SelectedNodes.Text,"parent")
treeobj.SelectedNodes = [];
end
end
Multiselect "on" will require few additional changes. If you base it the node property "Text" (as I did) each node will have to have unique name & editable will break it - it better done using the "Tag" property, or by hard-coding handle list & using "ismember"

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by