extend ui_list_setselection to allow to remove selections

Sat, 30 Aug 2025 10:18:09 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 30 Aug 2025 10:18:09 +0200
changeset 737
ac7f0869e8ae
parent 736
3ad4792ffadc
child 738
0dbf92544d4f

extend ui_list_setselection to allow to remove selections

ui/common/types.c file | annotate | diff | comparison | revisions
--- a/ui/common/types.c	Sat Aug 30 10:14:46 2025 +0200
+++ b/ui/common/types.c	Sat Aug 30 10:18:09 2025 +0200
@@ -627,10 +627,12 @@
 }
 
 UIEXPORT void ui_list_setselection(UiList *list, int index) {
-    if (list->setselection && index >= 0) {
-        UiListSelection sel;
-        sel.count = 1;
-        sel.rows = &index;
+    if (list->setselection) {
+        UiListSelection sel = { 0, NULL };
+        if(index >= 0) {
+            sel.count = 1;
+            sel.rows = &index;
+        }
         list->setselection(list, sel);
     }
 }

mercurial