From abf13d4ec112fc430b9fadea69455aa45d4e3cd6 Mon Sep 17 00:00:00 2001 From: Rockwell Schrock Date: Wed, 29 Jan 2025 23:07:06 -0500 Subject: On browser and file_browser screens, focus the first item when appearing --- lua/widgets.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lua/widgets.lua') diff --git a/lua/widgets.lua b/lua/widgets.lua index 5e18809b..0aac7705 100644 --- a/lua/widgets.lua +++ b/lua/widgets.lua @@ -306,10 +306,11 @@ function widgets.InfiniteList(parent, iterator, opts) fwd_iterator:prev() end - local function add_item(item, index) + local function add_item(item, index, item_opts) if not item then return end + item_opts = item_opts or {} local this_item = index local add_to_top = false if this_item < first_index then @@ -325,6 +326,9 @@ function widgets.InfiniteList(parent, iterator, opts) if add_to_top then btn:move_to_index(0) end + if item_opts.focus then + btn:focus() + end -- opts.callback should take an item and return a function matching the arg of onClicked if opts.callback then btn:onClicked(opts.callback(item)) @@ -361,7 +365,7 @@ function widgets.InfiniteList(parent, iterator, opts) if not val then break end - add_item(val, idx) + add_item(val, idx, { focus = (opts.focus_first_item and idx == 0) }) end return infinite_list -- cgit v1.2.3 From e343ffee5a4663374a77073a3e4370041f2fc431 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Feb 2025 17:23:24 +0000 Subject: Add playlist browser Add a menu item to main menu and associated browser for playlist files in the root of the SD card --- lua/widgets.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/widgets.lua') diff --git a/lua/widgets.lua b/lua/widgets.lua index 0aac7705..20f0cd2a 100644 --- a/lua/widgets.lua +++ b/lua/widgets.lua @@ -361,7 +361,7 @@ function widgets.InfiniteList(parent, iterator, opts) end for idx = 0, 8 do - local val = fwd_iterator() + local val = fwd_iterator:next() if not val then break end -- cgit v1.2.3