# HG changeset patch # User Olaf Wintermann # Date 1706613041 -3600 # Node ID 9335e9bbc1677476278faab3dc32c836e27d1eda # Parent 5dd24929f9f683dcd10de635739f01d896705662 call event handler after text input in the path textfield diff -r 5dd24929f9f6 -r 9335e9bbc167 ui/winui/text.cpp --- a/ui/winui/text.cpp Mon Jan 29 18:47:55 2024 +0100 +++ b/ui/winui/text.cpp Tue Jan 30 12:10:41 2024 +0100 @@ -242,23 +242,27 @@ return elms; } -void ui_pathtextfield_update(UiPathTextField* pb, const char *full_path) { +int ui_pathtextfield_update(UiPathTextField* pb, const char *full_path) { Grid grid = pb->grid; ui_pathelm_func getpathelm = pb->getpathelm; void* getpathelmdata = pb->getpathelmdata; + size_t full_path_len = full_path ? strlen(full_path) : 0; + + size_t nelm = 0; + UiPathElm* path_elm = getpathelm(full_path, full_path_len, &nelm, getpathelmdata); + if (!path_elm) { + return 1; + } + // hide textbox, show button panel pb->textbox.Visibility(Visibility::Collapsed); pb->buttons.Visibility(Visibility::Visible); // clear old buttons - ui_pathtextfield_clear(pb->buttons); + ui_pathtextfield_clear(pb->buttons); - size_t full_path_len = full_path ? strlen(full_path) : 0; - - size_t nelm = 0; - UiPathElm* path_elm = getpathelm(full_path, full_path_len, &nelm, getpathelmdata); ui_pathfield_free_pathelms(pb->current_path, pb->current_path_nelms); pb->current_path = path_elm; pb->current_path_nelms = nelm; @@ -298,6 +302,8 @@ j++; } + + return 0; } char* ui_path_textfield_get(UiString * str) { @@ -436,7 +442,17 @@ if (update) { std::wstring value(pathTextBox.Text()); char* full_path = wchar2utf8(value.c_str(), value.length()); - ui_pathtextfield_update(uipathbar, full_path); + + if (!ui_pathtextfield_update(uipathbar, full_path)) { + UiEvent evt; + evt.obj = obj; + evt.window = obj->window; + evt.document = obj->ctx->document; + evt.eventdata = full_path; + evt.intval = -1; + args.onactivate(&evt, args.onactivatedata); + } + free(full_path); }