application/demo_bindings.c

changeset 882
75de79b155e3
parent 873
78853bfc47cf
child 886
6f5e02fcb7b9
--- a/application/demo_bindings.c	Tue Oct 28 14:25:46 2025 +0100
+++ b/application/demo_bindings.c	Tue Oct 28 21:13:35 2025 +0100
@@ -65,10 +65,18 @@
     if(event->document) {
         ui_detach_document(event->obj->ctx, event->document);
     }
+    printf("selection: %d\n", event->intval);
     Document *doc = ui_list_get(wdata->doclist, event->intval);
     if(doc) {
+        char *s1 = ui_get(doc->id);
+        char *s2 = ui_get(doc->name);
+        printf("doc %s - %s\n", s1, s2);
         ui_attach_document(event->obj->ctx, doc);
+        
     }
+    //UiListSelection sel = ui_list_getselection(wdata->doclist);
+    //printf("sel: %d\n", sel.rows[0]);
+    //ui_listselection_free(sel);
 }
 
 void* doclist_get_value(void *elm, int col) {
@@ -92,7 +100,7 @@
         ui_llabel(obj, .varname = "name");
         ui_newline(obj);
         
-        ui_combobox(obj, .varname = "doclist", .colspan = 2, .onactivate = switch_document, .getvalue = doclist_get_value);
+        ui_combobox(obj, .varname = "doclist", .colspan = 2, .onactivate = switch_document, .getvalue = doclist_get_value, .colspan = 2, .hfill = TRUE);
         ui_newline(obj);
         
         ui_frame(obj, .label = "Document", .colspan = 2, .fill = TRUE) {
@@ -108,6 +116,7 @@
         ui_list_append(wdata->doclist, doc);
     }
     ui_list_update(wdata->doclist);
+    ui_list_setselection(wdata->doclist, 0);
     Document *doc = ui_list_get(wdata->doclist, 0);
     ui_attach_document(obj->ctx, doc);
     

mercurial