Propagator no longer segfaults when handling keynav

This commit is contained in:
Sasha Koshka 2023-03-04 01:48:16 -05:00
parent 5fc5af92df
commit dc5ddfc0bd
1 changed files with 7 additions and 11 deletions

View File

@ -330,16 +330,12 @@ func (propagator *Propagator) forFlexible (callback func (child elements.Flexibl
})
}
func (propagator *Propagator) firstFocused () (index int) {
index = -1
currentIndex := 0
propagator.forFocusable (func (child elements.Focusable) bool {
if child.Focused() {
index = currentIndex
return false
func (propagator *Propagator) firstFocused () int {
for index := 0; index < propagator.parent.CountChildren(); index ++ {
child, focusable := propagator.parent.Child(index).(elements.Focusable)
if focusable && child.Focused() {
return index
}
currentIndex ++
return true
})
return
}
return -1
}