diff --git a/docs/changes.md b/docs/changes.md index 6008625df..c1f37135d 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,9 @@ # 最新动态 +* 2019/12/17 + * 完善dialog\_confirm/dialog\_info等函数。 + * 增加widget\_set\_focusable函数。 + * 2019/12/13 * 修改窗口切到FOREGROUND把焦点设回去会导致如果当前页面有滚动控件时,页面会滚动的问题(感谢大恒提供补丁)。 * 修改widget在point_down少发了个leave事件的问题(感谢大恒提供补丁)。 diff --git a/src/widgets/dialog_helper.c b/src/widgets/dialog_helper.c index fb800849d..5bd3380c1 100644 --- a/src/widgets/dialog_helper.c +++ b/src/widgets/dialog_helper.c @@ -99,7 +99,9 @@ static widget_t* dialog_create_label(const char* text) { label = label_create(NULL, 0, 0, 0, 0); return_value_if_fail(label != NULL, NULL); - widget_set_tr_text(label, text); + if (text != NULL) { + widget_set_tr_text(label, text); + } label_resize_to_content(label, r.x, r.w, r.y, r.h); return label; @@ -161,6 +163,8 @@ ret_t dialog_info_ex(const char* text, const char* title_text, const char* theme ok = button_create(client, 0, 0, 0, 0); widget_set_tr_text(ok, "OK"); + widget_set_focused(ok, TRUE); + widget_set_focusable(ok, TRUE); widget_set_self_layout(ok, "default(x=c, y=bottom:10, w=50%, h=30)"); widget_on(ok, EVT_CLICK, on_ok_to_quit, dialog); @@ -218,11 +222,14 @@ ret_t dialog_confirm(const char* stitle, const char* text) { ok = button_create(client, 0, 0, 0, 0); widget_set_tr_text(ok, "OK"); + widget_set_focused(ok, TRUE); + widget_set_focusable(ok, TRUE); widget_use_style(ok, OK_STYLE_NAME); widget_set_self_layout(ok, "default(x=10%, y=bottom:10, w=30%, h=30)"); widget_on(ok, EVT_CLICK, on_ok_to_quit, dialog); cancel = button_create(client, 0, 0, 0, 0); + widget_set_focusable(cancel, TRUE); widget_set_tr_text(cancel, "Cancel"); widget_use_style(cancel, CANCEL_STYLE_NAME); widget_set_self_layout(cancel, "default(x=r:10%, y=bottom:10, w=30%, h=30)");