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.
()
| 245 | // prompting the user for the type of node to add |
| 246 | // If SyncNode is set, operates on Sync Tree. |
| 247 | func (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. |
nothing calls this directly
no test coverage detected