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

Method AddChildNode

core/treesync.go:247–269  ·  view source on GitHub ↗

AddChildNode adds a new child node to this one in the tree, prompting the user for the type of node to add If SyncNode is set, operates on Sync Tree.

()

Source from the content-addressed store, hash-verified

245// prompting the user for the type of node to add
246// If SyncNode is set, operates on Sync Tree.
247func (tr *Tree) AddChildNode() { //types:add
248 ttl := "Add child"
249 var typ *types.Type
250 if tr.SyncNode == nil {
251 typ = types.TypeByValue(tr.This)
252 } else {
253 typ = types.TypeByValue(tr.SyncNode)
254 }
255 d := NewBody().AddTitle(ttl).AddText("Number and type of items to insert:")
256 nd := &newItemsData{Number: 1, Type: typ}
257 NewForm(d).SetStruct(nd)
258 d.AddBottomBar(func(parent Widget) {
259 d.AddCancel(parent)
260 d.AddOK(parent).OnClick(func(e events.Event) {
261 if tr.SyncNode != nil {
262 tr.addSyncNodes(0, 0, nd.Type, nd.Number)
263 } else {
264 tr.addTreeNodes(0, 0, nd.Type, nd.Number)
265 }
266 })
267 })
268 d.RunDialog(tr)
269}
270
271// DeleteNode deletes the tree node or sync node corresponding
272// to this view node in the sync tree.

Callers

nothing calls this directly

Calls 13

addSyncNodesMethod · 0.95
addTreeNodesMethod · 0.95
TypeByValueFunction · 0.92
NewBodyFunction · 0.85
NewFormFunction · 0.85
AddTextMethod · 0.80
AddTitleMethod · 0.80
AddBottomBarMethod · 0.80
AddCancelMethod · 0.80
AddOKMethod · 0.80
RunDialogMethod · 0.80
SetStructMethod · 0.45

Tested by

no test coverage detected