Bugfix in Flex which led to a panic.

This commit is contained in:
Oliver 2020-08-18 14:03:38 +02:00
parent 3acd674ec1
commit 53d50e499b
2 changed files with 5 additions and 5 deletions

View File

@ -6,11 +6,11 @@ import "github.com/rivo/tview"
// center, given the provided primitive's size.
func Center(width, height int, p tview.Primitive) tview.Primitive {
return tview.NewFlex().
AddItem(tview.NewBox(), 0, 1, false).
AddItem(nil, 0, 1, false).
AddItem(tview.NewFlex().
SetDirection(tview.FlexRow).
AddItem(tview.NewBox(), 0, 1, false).
AddItem(nil, 0, 1, false).
AddItem(p, height, 1, true).
AddItem(tview.NewBox(), 0, 1, false), width, 1, true).
AddItem(tview.NewBox(), 0, 1, false)
AddItem(nil, 0, 1, false), width, 1, true).
AddItem(nil, 0, 1, false)
}

View File

@ -228,7 +228,7 @@ func (f *Flex) MouseHandler() func(action MouseAction, event *tcell.EventMouse,
func (f *Flex) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) {
return f.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p Primitive)) {
for _, item := range f.items {
if item != nil && item.Item.GetFocusable().HasFocus() {
if item.Item != nil && item.Item.GetFocusable().HasFocus() {
if handler := item.Item.InputHandler(); handler != nil {
handler(event, setFocus)
return