Browse Source

Fixed focus delegation.

tablepad
Oliver 5 years ago
parent
commit
1cc5331a5c
  1. 4
      application.go
  2. 6
      flex.go
  3. 5
      form.go
  4. 5
      frame.go
  5. 5
      pages.go

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

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

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

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

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

Loading…
Cancel
Save