mirror of https://github.com/rivo/tview.git
Bugfix in Flex which led to a panic.
This commit is contained in:
parent
3acd674ec1
commit
53d50e499b
|
@ -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)
|
||||
}
|
||||
|
|
2
flex.go
2
flex.go
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue