mirror of
https://github.com/rivo/tview.git
synced 2024-11-15 06:12:46 +00:00
Fixed scrolling issue in TreeView. Fixes #796
This commit is contained in:
parent
281d14d896
commit
5796b0cd5c
@ -584,9 +584,7 @@ func (t *TreeView) process(drawingAfter bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
t.step = 0
|
||||
t.currentNode = t.nodes[selectedIndex]
|
||||
t.movement = treeNone
|
||||
|
||||
// Move selection into viewport.
|
||||
if t.movement != treeScroll {
|
||||
@ -596,6 +594,11 @@ func (t *TreeView) process(drawingAfter bool) {
|
||||
if selectedIndex < t.offsetY {
|
||||
t.offsetY = selectedIndex
|
||||
}
|
||||
if t.movement != treeHome && t.movement != treeEnd {
|
||||
// treeScroll, treeHome, and treeEnd are handled by Draw().
|
||||
t.movement = treeNone
|
||||
t.step = 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If selection is not visible or selectable, select the first candidate.
|
||||
@ -635,7 +638,7 @@ func (t *TreeView) Draw(screen tcell.Screen) {
|
||||
}
|
||||
|
||||
// Scroll the tree, t.movement is treeNone after process() when there is a
|
||||
// selection.
|
||||
// selection, except for treeScroll, treeHome, and treeEnd.
|
||||
x, y, width, height := t.GetInnerRect()
|
||||
switch t.movement {
|
||||
case treeMove, treeScroll:
|
||||
|
Loading…
Reference in New Issue
Block a user