Manual scrolling in Grid
mkozjak opened this issue · comments
Thanks for this amazing project.
I have a question regarding Grid and grid.SetOffset method. Should I be "redrawing" my screen after setting the offset value via grid.SetOffset
?
I have a flex app that consists of two items split vertically - A list and a grid. I switch between these using Application.SetFocus
in my Application.SetInputCapture
callback.
Grid consists of multiple Lists, where the first one is automatically focused when set via Grid.AddItem
. This item captures the 'j' key in order to select the next list item, as shown in this excerpt:
trackLst.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Rune() {
case 'j':
if trackLst.GetCurrentItem()+1 == trackLst.GetItemCount() {
// skip to the next album if available
if a.currentAlbumIndex+1 == a.currentAlbumCount {
// do nothing, return default, because this is the last album
return nil
} else {
c.SetOffset(a.currentAlbumIndex+1, 0)
// FIXME: still need to somehow redraw the screen?
a.currentAlbumIndex = a.currentAlbumIndex + 1
return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)
}
}
return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)
}
return event
I am 100% sure c.SetOffset
works and the provided parameter to it is correct since after I switch back from a Grid root element to my List root element (via Tab) it scrolls itself to only show me the needed Grid element.
Should grid.SetOffset
be refreshing this app portion automatically or should I be doing something in addition?
Thanks!
I managed to mitigate this using Application.SetFocus giving it the primitive I want to focus, a next List instance.
Thanks!