mirror of
https://github.com/rivo/tview.git
synced 2025-04-24 13:48:56 +08: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.currentNode = t.nodes[selectedIndex]
|
||||||
t.movement = treeNone
|
|
||||||
|
|
||||||
// Move selection into viewport.
|
// Move selection into viewport.
|
||||||
if t.movement != treeScroll {
|
if t.movement != treeScroll {
|
||||||
@ -596,6 +594,11 @@ func (t *TreeView) process(drawingAfter bool) {
|
|||||||
if selectedIndex < t.offsetY {
|
if selectedIndex < t.offsetY {
|
||||||
t.offsetY = selectedIndex
|
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 {
|
} else {
|
||||||
// If selection is not visible or selectable, select the first candidate.
|
// 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
|
// 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()
|
x, y, width, height := t.GetInnerRect()
|
||||||
switch t.movement {
|
switch t.movement {
|
||||||
case treeMove, treeScroll:
|
case treeMove, treeScroll:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user