From 1cc5331a5c87e4dee8495414ba6f4c50efc70270 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Wed, 27 Dec 2017 22:55:50 +0100 Subject: [PATCH] Fixed focus delegation. --- application.go | 4 ---- flex.go | 6 ++++-- form.go | 5 ----- frame.go | 5 ----- pages.go | 5 ----- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/application.go b/application.go index c3dd560..6a215d6 100644 --- a/application.go +++ b/application.go @@ -239,10 +239,6 @@ func (a *Application) ResizeToFullScreen(p Primitive) *Application { // Blur() will be called on the previously focused primitive. Focus() will be // called on the new primitive. func (a *Application) SetFocus(p Primitive) *Application { - if p.InputHandler() == nil { - return a - } - a.Lock() if a.focus != nil { a.focus.Blur() diff --git a/flex.go b/flex.go index 18cf06e..db5b3ac 100644 --- a/flex.go +++ b/flex.go @@ -1,6 +1,8 @@ package tview -import "github.com/gdamore/tcell" +import ( + "github.com/gdamore/tcell" +) // Configuration values. const ( @@ -69,7 +71,7 @@ func (f *Flex) SetFullScreen(fullScreen bool) *Flex { // primitive receives focus. If multiple items have the "focus" flag set to // true, the first one will receive focus. func (f *Flex) AddItem(item Primitive, fixedSize, proportion int, focus bool) *Flex { - f.items = append(f.items, flexItem{Item: item, FixedSize: fixedSize, Proportion: proportion}) + f.items = append(f.items, flexItem{Item: item, FixedSize: fixedSize, Proportion: proportion, Focus: focus}) return f } diff --git a/form.go b/form.go index b9bced8..875790f 100644 --- a/form.go +++ b/form.go @@ -304,11 +304,6 @@ func (f *Form) Focus(delegate func(p Primitive)) { } } -// InputHandler returns the handler for this primitive. -func (f *Form) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) { - return func(event *tcell.EventKey, setFocus func(p Primitive)) {} -} - // HasFocus returns whether or not this primitive has focus. func (f *Form) HasFocus() bool { for _, item := range f.items { diff --git a/frame.go b/frame.go index 51bf3e4..a1a5b72 100644 --- a/frame.go +++ b/frame.go @@ -145,11 +145,6 @@ func (f *Frame) Focus(delegate func(p Primitive)) { delegate(f.primitive) } -// InputHandler returns the handler for this primitive. -func (f *Frame) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) { - return func(event *tcell.EventKey, setFocus func(p Primitive)) {} -} - // HasFocus returns whether or not this primitive has focus. func (f *Frame) HasFocus() bool { focusable, ok := f.primitive.(Focusable) diff --git a/pages.go b/pages.go index 4dbadc3..6995a32 100644 --- a/pages.go +++ b/pages.go @@ -217,8 +217,3 @@ func (p *Pages) Draw(screen tcell.Screen) { page.Item.Draw(screen) } } - -// InputHandler returns the handler for this primitive. -func (p *Pages) InputHandler() func(event *tcell.EventKey, setFocus func(p Primitive)) { - return func(event *tcell.EventKey, setFocus func(p Primitive)) {} -}