MCPcopy Index your code
hub / github.com/g3n/engine / InsertNodeAt

Method InsertNodeAt

gui/tree.go:282–296  ·  view source on GitHub ↗

InsertNodeAt inserts a new node at the specified position in this node If the position is invalid, the function panics

(pos int, text string)

Source from the content-addressed store, hash-verified

280// InsertNodeAt inserts a new node at the specified position in this node
281// If the position is invalid, the function panics
282func (n *TreeNode) InsertNodeAt(pos int, text string) *TreeNode {
283
284 if pos < 0 || pos > len(n.items) {
285 panic("TreeNode.InsertNodeAt(): Invalid position")
286 }
287 childNode := newTreeNode(text, n.tree, n)
288 // Insert item in the items array
289 n.items = append(n.items, nil)
290 copy(n.items[pos+1:], n.items[pos:])
291 n.items[pos] = childNode
292 if n.expanded {
293 n.updateItems()
294 }
295 return childNode
296}
297
298// AddNode adds a new node to this one and return its pointer
299func (n *TreeNode) AddNode(text string) *TreeNode {

Callers 1

AddNodeMethod · 0.95

Calls 2

updateItemsMethod · 0.95
newTreeNodeFunction · 0.85

Tested by

no test coverage detected