mirror of https://github.com/rivo/tview.git
Bugfix in pages focus.
This commit is contained in:
parent
b8e50f0e44
commit
5555b22427
13
pages.go
13
pages.go
|
@ -190,16 +190,19 @@ func (p *Pages) Focus(delegate func(p Primitive)) {
|
||||||
|
|
||||||
// refocus sets the focus to the topmost visible page but only if we have focus.
|
// refocus sets the focus to the topmost visible page but only if we have focus.
|
||||||
func (p *Pages) refocus() {
|
func (p *Pages) refocus() {
|
||||||
if !p.HasFocus() || p.setFocus == nil {
|
var (
|
||||||
return
|
topItem Primitive
|
||||||
}
|
hasFocus bool
|
||||||
var topItem Primitive
|
)
|
||||||
for _, page := range p.pages {
|
for _, page := range p.pages {
|
||||||
|
if page.Item.GetFocusable().HasFocus() {
|
||||||
|
hasFocus = true
|
||||||
|
}
|
||||||
if page.Visible {
|
if page.Visible {
|
||||||
topItem = page.Item
|
topItem = page.Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if topItem != nil {
|
if hasFocus && p.setFocus != nil && topItem != nil {
|
||||||
p.setFocus(topItem)
|
p.setFocus(topItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue