Fixed focus delegation.

This commit is contained in:
Oliver 2017-12-27 22:55:50 +01:00
parent c1b4809f2e
commit 1cc5331a5c
5 changed files with 4 additions and 21 deletions

View File

@ -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()

View File

@ -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
}

View File

@ -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 {

View File

@ -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)

View File

@ -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)) {}
}