Fix keymaps. Backtab

This commit is contained in:
2025-10-26 11:33:46 -05:00
parent d63e3a414a
commit 8f6e52df41
3 changed files with 39 additions and 14 deletions

View File

@@ -88,15 +88,30 @@ func (w *LinearLayout) Init(id string, s tcell.Style) {
active := w.findActive()
if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some
if w.widgets[0].Focusable() {
w.widgets[0].SetActive(true)
return true
for i := range w.widgets {
if w.widgets[i].Focusable() {
w.widgets[i].SetActive(true)
return true
}
}
return false
}
return w.ActivateNext()
}))
w.keyMap.Add(NewKey(BuildEK(tcell.KeyBacktab), func(ev *tcell.EventKey) bool {
active := w.findActive()
if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some
for i := len(w.widgets) - 1; i >= 0; i-- {
if w.widgets[i].Focusable() {
w.widgets[i].SetActive(true)
return true
}
}
return false
}
return w.ActivatePrev()
}))
}
func (w *LinearLayout) Id() string { return w.id }