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:
parent
8d551670db
commit
8a8f78a6dd
12
treeview.go
12
treeview.go
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user