2
0
mirror of https://github.com/rivo/tview.git synced 2024-11-12 19:10:28 +00:00

Added RemoveChild() to TreeNode. Resolves #561

This commit is contained in:
Oliver 2021-02-17 12:04:21 +01:00
parent 8d551670db
commit 8a8f78a6dd

View File

@ -133,6 +133,18 @@ func (n *TreeNode) AddChild(node *TreeNode) *TreeNode {
return n
}
// RemoveChild removes a child node from this node. If the child node cannot be
// found, nothing happens.
func (n *TreeNode) RemoveChild(node *TreeNode) *TreeNode {
for index, child := range n.children {
if child == node {
n.children = append(n.children[:index], n.children[index+1:]...)
break
}
}
return n
}
// SetSelectable sets a flag indicating whether this node can be selected by
// the user.
func (n *TreeNode) SetSelectable(selectable bool) *TreeNode {