Why does using 'copyobj' function with 'uitreenode' break node selection?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 22 Giu 2018
Modificato: MathWorks Support Team
il 15 Apr 2020
I am using 'copyobj' function to copy 'uitreenode' within the same 'uitree'. The interactive node selection within a 'uitree' misbehaves when a 'uitreenode' is copied within its parent 'uitree'. When a node is created using 'copyobj' function, the new node and the node it was created from can both be selected, even if the 'Multiselect' property was turned off.
The behavior also persists if a node is copied to a separate 'uitree' and then the new object's parent set to the original.
Risposta accettata
MathWorks Support Team
il 15 Apr 2020
Modificato: MathWorks Support Team
il 15 Apr 2020
This is a known bug which has been resolved in MATLAB R2018b.
If you are experiencing this issue in MATLAB R2018a or an earlier release, you can use one of the following workarounds:
1. The recommended workaround is to create a custom function to copy 'uitreenodes' as shown below:
function nodeCopy = treeNodeCopyObj(node, parent)
nodeProperties = get(node);
nodeProperties = rmfield(nodeProperties, 'BeingDeleted');
nodeProperties = rmfield(nodeProperties, 'Type');
nodeCopy = uitreenode(parent, nodeProperties);
end
2. Another potential workaround, which is less recommended, is to create a custom 'copyobj' function and put it in your path above the built-in version as shown below:
function nodeCopy = copyobj(node, parent)
if isa(node, 'matlab.ui.container.TreeNode')
nodeProperties = get(node);
nodeProperties = rmfield(nodeProperties, 'BeingDeleted');
nodeProperties = rmfield(nodeProperties, 'Type');
nodeCopy = uitreenode(parent, nodeProperties);
else
builtin('copyobj', node, parent)
end
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!