--- a/ui/winui/text.cpp Tue Jan 30 11:58:11 2024 +0100 +++ b/ui/winui/text.cpp Tue Jan 30 13:31:25 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); }