insertAt inserts a new node in the tree at given relative offset from this node, at the same (sibling) level, prompting for the type of node to insert If SyncNode is set, operates on Sync Tree.
(rel int, actNm string)
| 210 | // prompting for the type of node to insert |
| 211 | // If SyncNode is set, operates on Sync Tree. |
| 212 | func (tr *Tree) insertAt(rel int, actNm string) { |
| 213 | if tr.IsRoot(actNm) { |
| 214 | return |
| 215 | } |
| 216 | myidx := tr.IndexInParent() |
| 217 | if myidx < 0 { |
| 218 | return |
| 219 | } |
| 220 | myidx += rel |
| 221 | var typ *types.Type |
| 222 | if tr.SyncNode == nil { |
| 223 | typ = types.TypeByValue(tr.This) |
| 224 | } else { |
| 225 | typ = types.TypeByValue(tr.SyncNode) |
| 226 | } |
| 227 | d := NewBody().AddTitle(actNm).AddText("Number and type of items to insert:") |
| 228 | nd := &newItemsData{Number: 1, Type: typ} |
| 229 | NewForm(d).SetStruct(nd) |
| 230 | d.AddBottomBar(func(parent Widget) { |
| 231 | d.AddCancel(parent) |
| 232 | d.AddOK(parent).OnClick(func(e events.Event) { |
| 233 | parent := AsTree(tr.Parent) |
| 234 | if tr.SyncNode != nil { |
| 235 | parent.addSyncNodes(rel, myidx, nd.Type, nd.Number) |
| 236 | } else { |
| 237 | parent.addTreeNodes(rel, myidx, nd.Type, nd.Number) |
| 238 | } |
| 239 | }) |
| 240 | }) |
| 241 | d.RunDialog(tr) |
| 242 | } |
| 243 | |
| 244 | // AddChildNode adds a new child node to this one in the tree, |
| 245 | // prompting the user for the type of node to add |
no test coverage detected