ui/common/types.c

changeset 1055
02af1d4a88df
parent 1016
ccde46662db7
child 1056
541cec5e913c
--- a/ui/common/types.c	Fri Jan 23 16:25:39 2026 +0100
+++ b/ui/common/types.c	Sun Jan 25 10:28:37 2026 +0100
@@ -196,6 +196,12 @@
     }
 }
 
+UIEXPORT void ui_list_set_selection(UiList *list, UiListSelection sel) {
+    if(list->setselection) {
+        list->setselection(list, sel);
+    }
+}
+
 void ui_list_addobsv(UiList *list, ui_callback f, void *data) {
     list->observers = ui_add_observer(list->observers, f, data);
 }
@@ -789,11 +795,16 @@
 }
 
 
-UIEXPORT UiListSelection ui_list_getselection(UiList *list) {
+UIEXPORT int ui_list_getselection(UiList *list) {
+    int selection = -1;
     if (list->getselection) {
-        return list->getselection(list);
+        UiListSelection sel = list->getselection(list);
+        if(sel.count > 0) {
+            selection = sel.rows[0];
+        }
+        ui_listselection_free(sel);
     }
-    return (UiListSelection){ 0, NULL };
+    return selection;
 }
 
 UIEXPORT void ui_list_setselection(UiList *list, int index) {

mercurial