fix: improve keyboard capture events

This commit is contained in:
Dan Anglin 2023-04-23 04:27:16 +01:00
parent b16fe8eb60
commit 283da856ff
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
4 changed files with 19 additions and 16 deletions

View file

@ -45,7 +45,6 @@ func Open(path string) (Board, error) {
} }
} }
return board, nil return board, nil
} }

View file

@ -22,9 +22,16 @@ func (u *UI) newColumn(statusID int, statusName string) column {
cards.SetWrapAround(false) cards.SetWrapAround(false)
cards.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { cards.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 'h' || event.Key() == tcell.KeyLeft { switch event.Rune() {
case 'q':
u.pages.ShowPage(quitPageName)
u.SetFocus(u.quit)
case 'a':
u.pages.ShowPage(addPageName)
u.SetFocus(u.add)
case 'h':
u.shiftColumnFocus(shiftLeft) u.shiftColumnFocus(shiftLeft)
} else if event.Rune() == 'l' || event.Key() == tcell.KeyRight { case 'l':
u.shiftColumnFocus(shiftRight) u.shiftColumnFocus(shiftRight)
} }

View file

@ -65,14 +65,11 @@ func (u *UI) init() {
u.pages.AddPage(addPageName, u.add, false, false) u.pages.AddPage(addPageName, u.add, false, false)
u.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { u.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 'q' { switch event.Rune() {
u.pages.ShowPage(quitPageName) case 'o':
u.SetFocus(u.quit) if u.flex.HasFocus() && len(u.columns) == 0 {
} else if event.Rune() == 'o' {
u.openBoard("") u.openBoard("")
} else if event.Rune() == 'a' { }
u.pages.ShowPage(addPageName)
u.SetFocus(u.add)
} }
return event return event