# HG changeset patch # User Olaf Wintermann # Date 1780764465 -7200 # Node ID e5e5c177929478320c0fd95af871de935a87c475 # Parent 87a906a990e3c5ca15c4644c9d2380ac002fef8a set textview delegate (Cocoa) diff -r 87a906a990e3 -r e5e5c1779294 make/xcode/toolkit/toolkit/main.m --- a/make/xcode/toolkit/toolkit/main.m Sat Jun 06 18:37:04 2026 +0200 +++ b/make/xcode/toolkit/toolkit/main.m Sat Jun 06 18:47:45 2026 +0200 @@ -188,8 +188,18 @@ ui_var_set_int(event->obj->ctx, "tabview", 1); } +static void text_change(UiEvent *event, void *data) { + printf("text change\n"); +} + +static void text_changed(UiEvent *event, void *data) { + printf("text changed\n"); +} + void application_startup(UiEvent *event, void *data) { UiObject *obj = ui_splitview_window("My Window", TRUE); + ui_add_action(obj->ctx, "text_change", text_change, NULL); + ui_add_action(obj->ctx, "text_changed", text_changed, NULL); //WindowData *wdata = ui_malloc(obj->ctx, sizeof(WindowData)); //wdata->tbtoggle = ui_int_new(obj->ctx, "tbtoggle"); @@ -241,7 +251,7 @@ ui_tabview(obj, .padding = 20, .spacing = 10, .margin_left = 10, .margin_right = 10, .margin_bottom = 10, .fill = TRUE, .varname = "tabview") { ui_tab(obj, "Tab 1") { ui_button(obj, .label = "Next Tab", .onclick = next_tab); - ui_textarea(obj, .fill = TRUE); + ui_textarea(obj, .fill = TRUE, .onchange_action = "text_change", .ontextchanged_action = "text_changed"); } ui_tab(obj, "Tab 2") { //ui_button(obj, .label = "Tab 2 Content"); diff -r 87a906a990e3 -r e5e5c1779294 ui/cocoa/text.m --- a/ui/cocoa/text.m Sat Jun 06 18:37:04 2026 +0200 +++ b/ui/cocoa/text.m Sat Jun 06 18:47:45 2026 +0200 @@ -73,7 +73,9 @@ } if(args->onchange || args->ontextchanged || args->onchange_action || args->ontextchanged_action) { - + TextAreaDelegate * tad = [[TextAreaDelegate alloc] init:obj var:var args:args]; + textview.delegate = tad; + objc_setAssociatedObject(textview, "delegate", tad, OBJC_ASSOCIATION_RETAIN); } return (__bridge void*)scrollview;