240 *ret_nelm = n; |
240 *ret_nelm = n; |
241 |
241 |
242 return elms; |
242 return elms; |
243 } |
243 } |
244 |
244 |
245 void ui_pathtextfield_update(UiPathTextField* pb, const char *full_path) { |
245 int ui_pathtextfield_update(UiPathTextField* pb, const char *full_path) { |
246 Grid grid = pb->grid; |
246 Grid grid = pb->grid; |
247 |
247 |
248 ui_pathelm_func getpathelm = pb->getpathelm; |
248 ui_pathelm_func getpathelm = pb->getpathelm; |
249 void* getpathelmdata = pb->getpathelmdata; |
249 void* getpathelmdata = pb->getpathelmdata; |
|
250 |
|
251 size_t full_path_len = full_path ? strlen(full_path) : 0; |
|
252 |
|
253 size_t nelm = 0; |
|
254 UiPathElm* path_elm = getpathelm(full_path, full_path_len, &nelm, getpathelmdata); |
|
255 if (!path_elm) { |
|
256 return 1; |
|
257 } |
250 |
258 |
251 // hide textbox, show button panel |
259 // hide textbox, show button panel |
252 pb->textbox.Visibility(Visibility::Collapsed); |
260 pb->textbox.Visibility(Visibility::Collapsed); |
253 pb->buttons.Visibility(Visibility::Visible); |
261 pb->buttons.Visibility(Visibility::Visible); |
254 |
262 |
255 // clear old buttons |
263 // clear old buttons |
256 ui_pathtextfield_clear(pb->buttons); |
264 ui_pathtextfield_clear(pb->buttons); |
257 |
265 |
258 size_t full_path_len = full_path ? strlen(full_path) : 0; |
|
259 |
|
260 size_t nelm = 0; |
|
261 UiPathElm* path_elm = getpathelm(full_path, full_path_len, &nelm, getpathelmdata); |
|
262 ui_pathfield_free_pathelms(pb->current_path, pb->current_path_nelms); |
266 ui_pathfield_free_pathelms(pb->current_path, pb->current_path_nelms); |
263 pb->current_path = path_elm; |
267 pb->current_path = path_elm; |
264 pb->current_path_nelms = nelm; |
268 pb->current_path_nelms = nelm; |
265 |
269 |
266 // add new buttons |
270 // add new buttons |
434 buttons.Visibility(Visibility::Visible); |
440 buttons.Visibility(Visibility::Visible); |
435 filler.Visibility(Visibility::Visible); |
441 filler.Visibility(Visibility::Visible); |
436 if (update) { |
442 if (update) { |
437 std::wstring value(pathTextBox.Text()); |
443 std::wstring value(pathTextBox.Text()); |
438 char* full_path = wchar2utf8(value.c_str(), value.length()); |
444 char* full_path = wchar2utf8(value.c_str(), value.length()); |
439 ui_pathtextfield_update(uipathbar, full_path); |
445 |
|
446 if (!ui_pathtextfield_update(uipathbar, full_path)) { |
|
447 UiEvent evt; |
|
448 evt.obj = obj; |
|
449 evt.window = obj->window; |
|
450 evt.document = obj->ctx->document; |
|
451 evt.eventdata = full_path; |
|
452 evt.intval = -1; |
|
453 args.onactivate(&evt, args.onactivatedata); |
|
454 } |
|
455 |
440 free(full_path); |
456 free(full_path); |
441 } |
457 } |
442 |
458 |
443 //buttons.Focus(FocusState::Keyboard); |
459 //buttons.Focus(FocusState::Keyboard); |
444 } |
460 } |