aboutsummaryrefslogtreecommitdiff
path: root/libui/widget/list/list.ha
diff options
context:
space:
mode:
Diffstat (limited to 'libui/widget/list/list.ha')
-rw-r--r--libui/widget/list/list.ha12
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);