SetParent sets the parent of the given node to the given parent node. This is only for nodes with no existing parent; see [MoveToParent] to move nodes that already have a parent. It does not add the node to the parent's list of children; see [Node.AddChild] for a version that does. It automatically
(child Node, parent Node)
| 62 | // parent's list of children; see [Node.AddChild] for a version that does. |
| 63 | // It automatically gets the [Node.This] of the parent. |
| 64 | func SetParent(child Node, parent Node) { |
| 65 | nb := child.AsTree() |
| 66 | nb.Parent = parent.AsTree().This |
| 67 | setUniqueName(child, false) |
| 68 | child.AsTree().This.OnAdd() |
| 69 | if oca := nb.Parent.AsTree().OnChildAdded; oca != nil { |
| 70 | oca(child) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // MoveToParent removes the given node from its current parent |
| 75 | // and adds it as a child of the given new parent. |