improve builtin dialogs

This commit is contained in:
xianjimli 2019-12-17 14:34:49 +08:00
parent ac1eb03607
commit d87ca8eef2
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,9 @@
# 最新动态
* 2019/12/17
* 完善dialog\_confirm/dialog\_info等函数。
* 增加widget\_set\_focusable函数。
* 2019/12/13
* 修改窗口切到FOREGROUND把焦点设回去会导致如果当前页面有滚动控件时页面会滚动的问题感谢大恒提供补丁
* 修改widget在point_down少发了个leave事件的问题感谢大恒提供补丁

View File

@ -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)");