From 3b4e91f39cd48b12ec6926a264b7a7d5de5a4bb8 Mon Sep 17 00:00:00 2001 From: Simon Garrelou Date: Mon, 12 Dec 2022 20:35:27 +0100 Subject: Improve updateFooter() calls --- src/page_artists.go | 5 ++--- src/page_playlists.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/page_artists.go b/src/page_artists.go index 4175f3c..f67697c 100644 --- a/src/page_artists.go +++ b/src/page_artists.go @@ -34,20 +34,20 @@ func (a *app) artistsPage() tview.Primitive { a.loadAlbumInPanel(sel.id) a.tv.SetFocus(a.songsList) - a.updateFooter() }) a.artistsTree.SetBorderAttributes(tcell.AttrDim).SetBorder(true) + a.artistsTree.SetFocusFunc(func() { a.updateFooter() }) // Songs list for the selected album a.songsList = tview.NewList() a.songsList.ShowSecondaryText(false).SetHighlightFullLine(true) a.songsList.SetBorderAttributes(tcell.AttrDim).SetBorder(true) + a.songsList.SetFocusFunc(func() { a.updateFooter() }) // 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) - a.updateFooter() return nil } return event @@ -56,7 +56,6 @@ func (a *app) artistsPage() tview.Primitive { a.songsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { a.tv.SetFocus(a.artistsTree) - a.updateFooter() return nil } return event diff --git a/src/page_playlists.go b/src/page_playlists.go index 2ec8165..25b35ba 100644 --- a/src/page_playlists.go +++ b/src/page_playlists.go @@ -15,17 +15,18 @@ func (a *app) playlistsPage() tview.Primitive { SetHighlightFullLine(true). ShowSecondaryText(false) a.playlistsList.SetBorder(true).SetBorderAttributes(tcell.AttrDim) + a.playlistsList.SetFocusFunc(func() { a.updateFooter() }) a.playlistSongs = tview.NewList(). SetHighlightFullLine(true). ShowSecondaryText(false) a.playlistSongs.SetBorder(true).SetBorderAttributes(tcell.AttrDim) + a.playlistSongs.SetFocusFunc(func() { a.updateFooter() }) // Change the left-right keys to switch between the panels a.playlistsList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { a.tv.SetFocus(a.playlistSongs) - a.updateFooter() return nil } return event @@ -33,7 +34,6 @@ func (a *app) playlistsPage() tview.Primitive { a.playlistSongs.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyLeft || event.Key() == tcell.KeyRight { a.tv.SetFocus(a.playlistsList) - a.updateFooter() return nil } return event @@ -62,7 +62,6 @@ func (a *app) refreshPlaylists() error { a.playlistsList.AddItem(pl.Name, "", 0, func() { a.loadPlaylist(id) a.tv.SetFocus(a.playlistSongs) - a.updateFooter() }) } -- cgit v1.2.3