diff options
| author | Julian Hurst <julian.hurst92@gmail.com> | 2022-05-17 00:13:56 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst92@gmail.com> | 2022-05-17 00:13:56 +0200 |
| commit | a421424dda24a25f5e8c0387fff54296d821e8bb (patch) | |
| tree | c5be79562fb49f2ea44611f3ebaf853e06251118 /libui/widget | |
| parent | dbf800f59831852ace25f95d92875fe360735566 (diff) | |
| download | ilhare-a421424dda24a25f5e8c0387fff54296d821e8bb.tar.gz | |
Add list::setitems, sorting and decouple handlers from main.ha
Diffstat (limited to 'libui/widget')
| -rw-r--r-- | libui/widget/list/list.ha | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libui/widget/list/list.ha b/libui/widget/list/list.ha index 8500482..efed759 100644 --- a/libui/widget/list/list.ha +++ b/libui/widget/list/list.ha @@ -79,6 +79,18 @@ export fn finish(list: *widget::widget) void = { widget::finishcommon(list); }; +// Set the list's items. If the length of the given items is smaller than the +// list's current items, the cursor will be set to 0z and [[reframe]] will be +// called to reset the frame. +export fn setitems(list: *listwidget, items: str...) void = { + const reset = len(items) < len(list.items); + list.items = strings::dupall(items); + if (reset) { + list.cursor = 0z; + reframe(list); + }; +}; + // Add a listener to the given list. //export fn addlistener(list: *listwidget, l: listener) void = { //append(list.listeners, l); |
