From f8f5ec9f3b37464094b5264954a60c551304257a Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Tue, 6 Dec 2022 19:26:34 +0100 Subject: change focus w/ left-right, quit w/ q, F1-F3 --- src/page_artists.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/page_artists.go') diff --git a/src/page_artists.go b/src/page_artists.go index c064785..0e1cc72 100644 --- a/src/page_artists.go +++ b/src/page_artists.go @@ -18,6 +18,7 @@ func artistsPage(a *app) tview.Primitive { SetColumns(40, 0). SetBorders(true) + // Artist & album list root := tview.NewTreeNode("Subsonic server").SetColor(tcell.ColorYellow) a.artistsTree = tview.NewTreeView(). SetRoot(root). @@ -38,9 +39,27 @@ func artistsPage(a *app) tview.Primitive { a.tv.SetFocus(a.songsList) }) + // Songs list for the selected album a.songsList = tview.NewList() a.songsList.ShowSecondaryText(false) + // Change the left-right keys to switch between the panels + a.artistsTree.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { + a.tv.SetFocus(a.songsList) + return nil + } + return event + }) + + a.songsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { + a.tv.SetFocus(a.artistsTree) + return nil + } + return event + }) + grid.AddItem(a.artistsTree, 0, 0, 1, 1, 0, 0, true) grid.AddItem(a.songsList, 0, 1, 1, 2, 0, 0, false) -- cgit v1.2.3