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

Method NewChild

tree/nodebase.go:317–323  ·  view source on GitHub ↗

NewChild creates a new child of the given type and adds it at the end of the list of children. The name defaults to the ID (kebab-case) name of the type, plus the [Node.NumLifetimeChildren] of the parent.

(typ *types.Type)

Source from the content-addressed store, hash-verified

315// of the list of children. The name defaults to the ID (kebab-case) name
316// of the type, plus the [Node.NumLifetimeChildren] of the parent.
317func (n *NodeBase) NewChild(typ *types.Type) Node {
318 kid := newOfType(typ)
319 InitNode(kid)
320 n.Children = append(n.Children, kid)
321 SetParent(kid, n)
322 return kid
323}
324
325// InsertChild adds given child at position in children list.
326// The kid node is assumed to not be on another tree (see [MoveToParent])

Callers 3

TestNodeEmbedNewChildFunction · 0.80
TestNodePathFunction · 0.80
NewOfTypeFunction · 0.80

Calls 3

newOfTypeFunction · 0.85
InitNodeFunction · 0.85
SetParentFunction · 0.85

Tested by 2

TestNodeEmbedNewChildFunction · 0.64
TestNodePathFunction · 0.64