Being able to store multiple user selected values from a tree, MATLAB APP Designer

29 ビュー (過去 30 日間)
Kevin Hanekom
Kevin Hanekom 2022 年 3 月 7 日
回答済み: Dinesh 2023 年 11 月 15 日
Hello everyone! I have been trying for the last couple hours to figure out how to store the values a user would select from a tree, while also being able to pickup when the user deselects a previously selected node. I havent found much insight or previous questions on how this might be accomplished.
For instance,
If the user selects the above two options, I notice that in the app.Tree.CheckedNodes it stores a 2x1 TreeNode array with the values I need to "detect" embded within. How would I be able to scan for the user selcted data?? Bellow is the mentioned function.
function TreeCheckedNodesChanged(app, event)
checkedNodes.Text = app.Tree.CheckedNodes;
Selc = checkedNodes.Text
if contains(Selc,"3D Yield Surface")
app.Checked(1) = [1];
else
app.Checked(1) = 0;
end
if contains(Selc,'Yield Strength vs Orientation')
app.Checked(2) = [1];
else
app.Checked(2) = 0;
end
if contains(Selc,'Actual vs Predicted')
app.Checked(3) = [1];
else
app.Checked(3) = 0;
end
app.UITable.ColumnName = {app.Checked};
That app.Checked bit is just so I could check if my code was working in real time, all it is supposed to do is store if the user made the change, please let me know if you see any better way to accomplish this aswell.
Thank you again and again!
Kevin
  1 件のコメント
Aubai
Aubai 2022 年 10 月 6 日
Data.Tasks = ismember(app.Tree.Children.Children,app.Tree.CheckedNodes);

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

回答 (1 件)

Dinesh
Dinesh 2023 年 11 月 15 日
Hi Kevin.
You can use "Properties" to store the data in your app. The following link will help you:
Once a property is defined, identify parts in your code where you would like the variable's data to be stored. Now assign the appropriate property's value to the state variable.
In your case, when the callback function is called when the checkbox is checked or unchecked, you can programmatically find out which checkbox is checked or unchecked after which the property variables can be changed. These properties that are stored can be accessed by other functions and callbacks to perform operations.

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by