Browse Source

Fix scrolling Table with PageDown and PageUp when some fixedRows are not visible

tablepad
Trevor Slocum 2 years ago
parent
commit
d815ca837d
  1. 18
      table.go

18
table.go

@ -1159,27 +1159,37 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi @@ -1159,27 +1159,37 @@ func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p Primi
}
pageDown = func() {
offsetAmount := t.visibleRows - t.fixedRows
if offsetAmount < 0 {
offsetAmount = 0
}
if t.rowsSelectable {
t.selectedRow += t.visibleRows - t.fixedRows
t.selectedRow += offsetAmount
if t.selectedRow >= len(t.cells) {
t.selectedRow = len(t.cells) - 1
}
next()
} else {
t.rowOffset += t.visibleRows - t.fixedRows
t.rowOffset += offsetAmount
}
}
pageUp = func() {
offsetAmount := t.visibleRows - t.fixedRows
if offsetAmount < 0 {
offsetAmount = 0
}
if t.rowsSelectable {
t.selectedRow -= t.visibleRows - t.fixedRows
t.selectedRow -= offsetAmount
if t.selectedRow < 0 {
t.selectedRow = 0
}
previous()
} else {
t.trackEnd = false
t.rowOffset -= t.visibleRows - t.fixedRows
t.rowOffset -= offsetAmount
}
}
)

Loading…
Cancel
Save