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

Allow changing current node during handler

Avoids wrong handler being called or even crash on nil
This commit is contained in:
Chris Miller 2020-04-17 02:12:37 +00:00
parent 8e06c826b3
commit 77ccc1ff41

View File

@ -681,12 +681,13 @@ func (t *TreeView) Draw(screen tcell.Screen) {
func (t *TreeView) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {
return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
selectNode := func() {
if t.currentNode != nil {
node := t.currentNode
if node != nil {
if t.selected != nil {
t.selected(t.currentNode)
t.selected(node)
}
if t.currentNode.selected != nil {
t.currentNode.selected()
if node.selected != nil {
node.selected()
}
}
}