tui-go icon indicating copy to clipboard operation
tui-go copied to clipboard

Move in a List does not work when using ScrollArea

Open Lallassu opened this issue 7 years ago • 2 comments

When I add a ScrollArea to a VBox which contains a List and then add the list to the FocusChain I cannot move in the list with arrow-keys. It works fine as long as I don't have a ScrollArea around it. Am I missing something or is this a bug?

l := tui.NewList()
l.AddItems("line1", "line2", "line3", "line4")
l.SetSelected(0)
userScroll := tui.NewScrollArea(l)
userScroll.SetSizePolicy(tui.Preferred, tui.Maximum)
sidebar1 := tui.NewVBox(userScroll)
sidebar1.SetBorder(true)
sidebar1.SetTitle("List1")
sidebar.Prepend(sidebar1)
....
focusChain.Set(l, l2) // l2 is a list without a ScrollArea

Note that I have a "main" sidebar which holds 2 other sidebars (VBoxes) that contain a list each. One of them have a ScrollArea. And that one will not scroll when selected.

Lallassu avatar Jun 03 '18 10:06 Lallassu

Looks like the key event is not being forwarded to the underlying widget.

ScrollArea should reimplement OnKeyEvent(ev KeyEvent) and pass on the event to the widget it encapsulates. Here's it's done for Box: https://github.com/marcusolsson/tui-go/blob/master/box.go#L213

marcusolsson avatar Jun 11 '18 12:06 marcusolsson

I'd be happy to accept a PR, otherwise I should be able to add a fix for this during the week.

marcusolsson avatar Jun 11 '18 12:06 marcusolsson