필터 지우기
필터 지우기

How to disable uitreenode?

조회 수: 15 (최근 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 CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by