【MATLAB】チェ​ックボックスツリーの​チェック状態を取得す​る方法

チェックボックスツリーを作成しました。
このとき、各ノードのチェック状態がONかoFFかを取得したいですが、方法が分かりません。
例:child2 == on のときLEDが光る 等を行いたいです。よろしくお願いいたします。
fig = uifigure('Name','config');
checkbox = uitree(fig,'checkbox','Position',[170 20 150 200]);
parent = uitreenode(checkbox,'Text','pare');
chil1 = uitreenode(parent,'Text','chil1');
chil2 = uitreenode(parent,'Text','chil2');
chil3 = uitreenode(parent,'Text','chil3');
expand(checkbox)

 Réponse acceptée

交感神経優位なあかべぇ
Modifié(e) : 交感神経優位なあかべぇ le 17 Oct 2023

2 votes

各ノードのチェック状態は、checkboxtreeのCheckedNodesプロパティで管理されているようです。
child2の状態を判定する例を書きます。
fig = uifigure('Name','config');
checkbox = uitree(fig,'checkbox','Position',[170 20 150 200]);
parent = uitreenode(checkbox,'Text','pare');
chil1 = uitreenode(parent,'Text','chil1');
chil2 = uitreenode(parent,'Text','chil2');
chil3 = uitreenode(parent,'Text','chil3');
expand(checkbox);
isCheckedChil2 = ismember(chil2, checkbox.CheckedNodes) % child2の状態の判定

Plus de réponses (0)

Catégories

En savoir plus sur 乱数発生器 dans Centre d'aide et File Exchange

Produits

Version

R2022a

Community Treasure Hunt

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

Start Hunting!