MCPcopy Create free account
hub / github.com/cogentcore/core / SetParent

Function SetParent

tree/admin.go:64–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

62// parent's list of children; see [Node.AddChild] for a version that does.
63// It automatically gets the [Node.This] of the parent.
64func 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.

Callers 11

newPartsMethod · 0.92
newBodySceneFunction · 0.92
newScrimFunction · 0.92
configScrollMethod · 0.92
UpdateSliceFunction · 0.85
AddChildMethod · 0.85
NewChildMethod · 0.85
InsertChildMethod · 0.85
TestSetUniqueNameFunction · 0.85
NewFunction · 0.85
UpdateMethod · 0.85

Calls 3

setUniqueNameFunction · 0.85
AsTreeMethod · 0.65
OnAddMethod · 0.65

Tested by 1

TestSetUniqueNameFunction · 0.68