application/main.c

changeset 143
d499b29d7cb6
parent 142
46448d38885c
child 144
29d98cff4f56
--- a/application/main.c	Sat Nov 11 08:34:06 2017 +0100
+++ b/application/main.c	Sat Nov 11 11:59:06 2017 +0100
@@ -76,10 +76,10 @@
     Document *doc = ui_document_new(sizeof(Document));
     UiContext *ctx = ui_document_context(doc);
     
-    //doc->text = ui_text_new(ctx, "text");
-    //doc->t1 = ui_string_new(ctx, "t1");
-    //doc->t2 = ui_string_new(ctx, "t2");
-    //doc->t3 = ui_string_new(ctx, "t3");
+    doc->text = ui_text_new(ctx, "text");
+    doc->t1 = ui_string_new(ctx, "t1");
+    doc->t2 = ui_string_new(ctx, "t2");
+    doc->t3 = ui_string_new(ctx, "t3");
     
     doc->i = ui_int_new(ctx, "int");
     return doc;
@@ -93,6 +93,10 @@
     ui_set_document(event->obj, newd);
 }
 
+void observ(UiEvent *event, void *data) {
+    printf("observ: %s\n", (char*)data);
+}
+
 void application_startup(UiEvent *event, void *data) {
     //Document *doc = create_doc();
     d1 = create_doc();
@@ -106,6 +110,11 @@
     ui_radiobutton_nv(obj, "2", "int");
     ui_radiobutton_nv(obj, "3", "int");
     
+    ui_textfield_nv(obj, "t1");
+    ui_textarea_nv(obj, "text");
+    d1->t1->observers = ui_add_observer(d1->t1->observers, observ, "t1");
+    d1->text->observers = ui_add_observer(d1->text->observers, observ, "text");
+    
     ui_button(obj, "Switch Document", action_newdoc, NULL);
     
     ui_show(obj);

mercurial