Skip to content

Commit

Permalink
More functionally correct TreeViewNode
Browse files Browse the repository at this point in the history
Changed where parentNode is set so it's more in line with removeNode

added addComponentAt override for functional sorting.
  • Loading branch information
NB-NutBoi committed Nov 28, 2023
1 parent 701247a commit d61f0f2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion haxe/ui/containers/TreeViewNode.hx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class TreeViewNode extends VBox {
private class AddNode extends Behaviour {
public override function call(param:Any = null):Variant {
var node = new TreeViewNode();
node.parentNode = cast(_component, TreeViewNode);
node.data = param;
_component.addComponent(node);
return node;
Expand Down Expand Up @@ -382,6 +381,7 @@ private class TreeViewNodeBuilder extends CompositeBuilder {
}

if ((child is TreeViewNode)) {
cast(child, TreeViewNode).parentNode = _node;
if (_childContainer == null) {
_childContainer = new VBox();
if (_node.expanded == true) {
Expand All @@ -399,6 +399,31 @@ private class TreeViewNodeBuilder extends CompositeBuilder {

return null;
}

public override function addComponentAt(child:Component, index:Int) {
if (child == _renderer || child == _childContainer) {
return null;
}

if ((child is TreeViewNode)) {
cast(child, TreeViewNode).parentNode = _node;
if (_childContainer == null) {
_childContainer = new VBox();
if (_node.expanded == true) {
_childContainer.show();
} else {
_childContainer.hide();
}
_childContainer.addClass("treenode-child-container");
_childContainer.id = "treenode-child-container";
_node.addComponent(_childContainer);
}
changeToExpandableRenderer();
return _childContainer.addComponentAt(child,index);
}

return null;
}

public override function removeComponent(child:Component, dispose:Bool = true, invalidate:Bool = true) {
if ((child is TreeViewNode)) {
Expand Down

0 comments on commit d61f0f2

Please sign in to comment.