InsertNodeAt inserts a new node at the specified position in this node If the position is invalid, the function panics
(pos int, text string)
| 280 | // InsertNodeAt inserts a new node at the specified position in this node |
| 281 | // If the position is invalid, the function panics |
| 282 | func (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 |
| 299 | func (n *TreeNode) AddNode(text string) *TreeNode { |
no test coverage detected