application/main.c

changeset 42
29b2821d1262
parent 39
4e66271541e8
child 45
cfeb2d5f1332
--- a/application/main.c	Thu May 15 22:13:25 2014 +0200
+++ b/application/main.c	Fri May 16 16:19:46 2014 +0200
@@ -51,6 +51,20 @@
     return NULL;
 }
 
+void action_activate(UiEvent *event, void *data) {
+    UiListSelection *selection = event->eventdata;
+    printf("activate: %d\n", event->intval);
+}
+
+void action_select(UiEvent *event, void *data) {
+    UiListSelection *selection = event->eventdata;
+    printf("selection[%d]: ", selection->count);
+    for(int i=0;i<selection->count;i++) {
+        printf("%d ", selection->rows[i]);
+    }
+    printf("\n");
+}
+
 int main(int argc, char** argv) { 
     ui_init("app1", argc, argv);
     ui_locales_dir("/opt/app1/locales");
@@ -67,6 +81,8 @@
     
     UiModelInfo *model = ui_model_info(window->ctx, UI_STRING, "Name", UI_STRING, "Email", -1);
     model->getvalue = (ui_model_getvalue_f)person_getvalue;
+    model->activate = action_activate;
+    model->selection = action_select;
     UiList *list = ui_list_new();
     Person *p1 = ui_malloc(window->ctx, sizeof(Person));
     Person *p2 = ui_malloc(window->ctx, sizeof(Person));

mercurial