diff options
| author | rdsh <rdsh@noreply.codeberg.org> | 2025-02-05 21:57:45 +0000 |
|---|---|---|
| committer | rdsh <rdsh@noreply.codeberg.org> | 2025-02-05 21:57:45 +0000 |
| commit | 2ec84a1393331f57f8402bce66d337c0dd255f64 (patch) | |
| tree | 30f271bf10988a9717abdf266d135e3ec0ae2d31 /lua/widgets.lua | |
| parent | ddcd06dbca61fc55a7c2cd68f82f8cfe7b4c5cbf (diff) | |
| parent | 9ecb79a264daa7896ce7d5a65592c05631213d5a (diff) | |
| download | tangara-fw-2ec84a1393331f57f8402bce66d337c0dd255f64.tar.gz | |
Merge pull request 'main' (#1) from cool-tech-zone/tangara-fw:main into main
Reviewed-on: https://codeberg.org/rdsh/tangara-fw/pulls/1
Diffstat (limited to 'lua/widgets.lua')
| -rw-r--r-- | lua/widgets.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/widgets.lua b/lua/widgets.lua index 5e18809b..20f0cd2a 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)) @@ -357,11 +361,11 @@ 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 - add_item(val, idx) + add_item(val, idx, { focus = (opts.focus_first_item and idx == 0) }) end return infinite_list |
