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) { func (propagator *Propagator) firstFocused () int {
index = -1 for index := 0; index < propagator.parent.CountChildren(); index ++ {
currentIndex := 0 child, focusable := propagator.parent.Child(index).(elements.Focusable)
propagator.forFocusable (func (child elements.Focusable) bool { if focusable && child.Focused() {
if child.Focused() { return index
index = currentIndex
return false
} }
currentIndex ++ }
return true return -1
})
return
} }