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

Method AddChild

tree/nodebase.go:308–312  ·  view source on GitHub ↗

Adding and Inserting Children: AddChild adds given child at end of children list. The kid node is assumed to not be on another tree (see [MoveToParent]) and the existing name should be unique among children.

(kid Node)

Source from the content-addressed store, hash-verified

306// The kid node is assumed to not be on another tree (see [MoveToParent])
307// and the existing name should be unique among children.
308func (n *NodeBase) AddChild(kid Node) {
309 InitNode(kid)
310 n.Children = append(n.Children, kid)
311 SetParent(kid, n) // key to set new parent before deleting: indicates move instead of delete
312}
313
314// NewChild creates a new child of the given type and adds it at the end
315// of the list of children. The name defaults to the ID (kebab-case) name

Callers 11

TestNodeAddChildFunction · 0.95
pasteChildrenSyncMethod · 0.45
pasteChildrenMethod · 0.45
RunMainWindowMethod · 0.45
makeSceneBarsMethod · 0.45
NewValueFunction · 0.45
AddFromLibraryMethod · 0.45
AddFromLibraryMethod · 0.45
UnmarshalXMLMethod · 0.45
TestNodeEmbedAddChildFunction · 0.45
MoveToParentFunction · 0.45

Calls 2

InitNodeFunction · 0.85
SetParentFunction · 0.85

Tested by 2

TestNodeAddChildFunction · 0.76
TestNodeEmbedAddChildFunction · 0.36