mirror of https://github.com/rivo/tview.git
Fixed focus delegation.
This commit is contained in:
parent
c1b4809f2e
commit
1cc5331a5c
|
@ -239,10 +239,6 @@ func (a *Application) ResizeToFullScreen(p Primitive) *Application {
|
||||||
// Blur() will be called on the previously focused primitive. Focus() will be
|
// Blur() will be called on the previously focused primitive. Focus() will be
|
||||||
// called on the new primitive.
|
// called on the new primitive.
|
||||||
func (a *Application) SetFocus(p Primitive) *Application {
|
func (a *Application) SetFocus(p Primitive) *Application {
|
||||||
if p.InputHandler() == nil {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
a.Lock()
|
a.Lock()
|
||||||
if a.focus != nil {
|
if a.focus != nil {
|
||||||
a.focus.Blur()
|
a.focus.Blur()
|
||||||
|
|
6
flex.go
6
flex.go
|
@ -1,6 +1,8 @@
|
||||||
package tview
|
package tview
|
||||||
|
|
||||||
import "github.com/gdamore/tcell"
|
import (
|
||||||
|
"github.com/gdamore/tcell"
|
||||||
|
)
|
||||||
|
|
||||||
// Configuration values.
|
// Configuration values.
|
||||||
const (
|
const (
|
||||||
|
@ -69,7 +71,7 @@ func (f *Flex) SetFullScreen(fullScreen bool) *Flex {
|
||||||
// primitive receives focus. If multiple items have the "focus" flag set to
|
// primitive receives focus. If multiple items have the "focus" flag set to
|
||||||
// true, the first one will receive focus.
|
// true, the first one will receive focus.
|
||||||
func (f *Flex) AddItem(item Primitive, fixedSize, proportion int, focus bool) *Flex {
|
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
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
form.go
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.
|
// HasFocus returns whether or not this primitive has focus.
|
||||||
func (f *Form) HasFocus() bool {
|
func (f *Form) HasFocus() bool {
|
||||||
for _, item := range f.items {
|
for _, item := range f.items {
|
||||||
|
|
5
frame.go
5
frame.go
|
@ -145,11 +145,6 @@ func (f *Frame) Focus(delegate func(p Primitive)) {
|
||||||
delegate(f.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.
|
// HasFocus returns whether or not this primitive has focus.
|
||||||
func (f *Frame) HasFocus() bool {
|
func (f *Frame) HasFocus() bool {
|
||||||
focusable, ok := f.primitive.(Focusable)
|
focusable, ok := f.primitive.(Focusable)
|
||||||
|
|
5
pages.go
5
pages.go
|
@ -217,8 +217,3 @@ func (p *Pages) Draw(screen tcell.Screen) {
|
||||||
page.Item.Draw(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…
Reference in New Issue