diff -r 822fcb83bdf1 -r 8c028965410a ui/gtk/text.c --- a/ui/gtk/text.c Tue Oct 29 11:52:01 2024 +0100 +++ b/ui/gtk/text.c Tue Oct 29 17:52:06 2024 +0100 @@ -536,8 +536,10 @@ UiVar* var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_STRING); UiTextField *uitext = malloc(sizeof(UiTextField)); - uitext->ctx = obj->ctx; + uitext->obj = obj; uitext->var = var; + uitext->onchange = args.onchange; + uitext->onchangedata = args.onchangedata; g_signal_connect( textfield, @@ -576,7 +578,9 @@ value->value.ptr = NULL; value->value.free = NULL; value->obj = GTK_ENTRY(textfield); - + } + + if(args.onchange || var) { g_signal_connect( textfield, "changed", @@ -605,15 +609,20 @@ } void ui_textfield_changed(GtkEditable *editable, UiTextField *textfield) { - // changed event is only registered, if the textfield->var != NULL UiString *value = textfield->var->value; - if(value->observers) { - UiEvent e; - e.obj = textfield->ctx->obj; - e.window = e.obj->window; - e.document = textfield->ctx->document; - e.eventdata = value; - e.intval = 0; + + UiEvent e; + e.obj = textfield->obj; + e.window = e.obj->window; + e.document = textfield->obj->ctx->document; + e.eventdata = value; + e.intval = 0; + + if(textfield->onchange) { + textfield->onchange(&e, textfield->onchangedata); + } + + if(textfield->var) { ui_notify_evt(value->observers, &e); } }