Hi There,
Having fun with the experimental TreeView,
I am stumbling upon a use case : Programatically selecting a node.
So I managed to expand the parents with “expandable = true” but the doing “myTree.selectedNode = myCoolNode;” the selection is not rendered though if I trace the myTree.selectedNode it returns the node obviously.
Any leads ?
Cheers
Bruno
Sounds like a bug / oversight - ill check it out a little later - thanks for reporting it!
Cheers,
Ian
1 Like
Do you have a bit more info here (or a minimal repro), just tried and it all seems fine:
Cheers,
Ian
1 Like
var tv1 = main.findComponent(“mytree”, TreeView);
var root = tv1.addNode({ text: “root A”, icon: “haxeui-core/styles/default/haxeui_tiny.png” });
root.expanded = true;
var child = root.addNode({ text: “child A-1”, icon: “haxeui-core/styles/default/haxeui_tiny.png” });
child.expanded = true;
child.addNode({ text: “child A-1-1”, icon: “haxeui-core/styles/default/haxeui_tiny.png” });
child.addNode({ text: “child A-1-2”, icon: “haxeui-core/styles/default/haxeui_tiny.png” });
var c3 = child.addNode({ text: “child A-1-3”, icon: “haxeui-core/styles/default/haxeui_tiny.png” });
tv1.selectedNode = c3;
trace(tv1.selectedNode.data.text); //child A-1-3
Renders :
I would like :
(i am building the tree and selection from http parameters recieved)¨
Ah, ok, yeah - i can repro now. The issue was that the tree view wasnt “ready” when selectedNode was being set - usually this wouldnt be an issue since these types of props should really be “behaviours” and that should then be taken care of - but since the tree is experimental i havent used the behaviour system (yet)
However, for now ive patched in a fix. (latest haxeui-core - git version)
Cheers,
Ian
2 Likes
Works perfectly !
seeing the fix is insightful
Thanks Ian!
1 Like
Its a shitty fix - when using behaviours it will automatically call things at the correct part of the update sequence - ie, when its ready (fyi: the only reason i set _selectedNode
to null
is because the property has a if (_selectedNode == value) return;
)
Behaviour mechanism is still a misery to me. Would really need to grasp it one day to be more helpful…
Ill write a guide at some point, its really quite simple
2 Likes