mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
edit support cancelable prop
This commit is contained in:
parent
e41634217c
commit
4a76e5ed64
@ -116,6 +116,7 @@
|
||||
<normal bg_color="#f0f0f0" />
|
||||
<focused bg_color="#f0f0f0" border_color="black"/>
|
||||
<disable bg_color="gray" text_color="#d0d0d0" />
|
||||
<changed bg_color="#f0f0f0" text_color="#ee0000" />
|
||||
<error bg_color="#f0f0f0" text_color="red" />
|
||||
<empty bg_color="#f0f0f0" text_color="#a0a0a0" />
|
||||
<empty_focus bg_color="#f0f0f0" text_color="#a0a0a0" border_color="black"/>
|
||||
|
@ -64,6 +64,10 @@
|
||||
<label w="30%" text="Text"/>
|
||||
<edit w="70%" style="line" tips="underline" text="" action_text="done"/>
|
||||
</list_item>
|
||||
<list_item style="empty" children_layout="default(r=1,c=0,ym=1)">
|
||||
<label w="30%" text="Custom"/>
|
||||
<edit w="70%" tips="custom keyboard" text="" keyboard="kb_foo" cancelable="true"/>
|
||||
</list_item>
|
||||
</scroll_view>
|
||||
<scroll_bar_d name="bar" x="right" y="0" w="12" h="100%" value="0"/>
|
||||
</list_view>
|
||||
|
1145
dllexports/awtk.def
1145
dllexports/awtk.def
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,9 @@
|
||||
# 最新动态
|
||||
|
||||
* 2020/08/20
|
||||
* 软键盘支持“clear"/"cancel"两个功能按钮。
|
||||
* edit 支持cancelable属性,为TRUE时,如果内容有变化,会设置编辑器的状态为changed,所以此时编辑器需要支持changed状态的style。
|
||||
|
||||
* 2020/08/19
|
||||
* 完善 app conf 保存 json 时字符串转义处理。
|
||||
* 完整 ui serializer,增加 xml 预处理指令。
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
TK_CONST_DATA_ALIGN(const unsigned char ui_edit[]) = {
|
||||
0x04,0x00,0x01,0x01,0x26,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,
|
||||
0x04,0x00,0x01,0x01,0x6b,0x17,0x00,0x00,0x00,0x00,0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
@ -272,16 +272,33 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_edit[]) = {
|
||||
0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x77,0x3d,0x37,0x30,0x25,
|
||||
0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x6c,0x69,0x6e,0x65,0x00,0x74,0x69,0x70,0x73,0x00,0x75,0x6e,
|
||||
0x64,0x65,0x72,0x6c,0x69,0x6e,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x00,0x61,0x63,0x74,0x69,0x6f,0x6e,
|
||||
0x5f,0x74,0x65,0x78,0x74,0x00,0x64,0x6f,0x6e,0x65,0x00,0x00,0x00,0x00,0x00,0x73,0x63,0x72,0x6f,0x6c,
|
||||
0x6c,0x5f,0x62,0x61,0x72,0x5f,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x64,
|
||||
0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,
|
||||
0x6c,0x74,0x28,0x78,0x3d,0x72,0x69,0x67,0x68,0x74,0x2c,0x79,0x3d,0x30,0x2c,0x77,0x3d,0x31,0x32,0x2c,
|
||||
0x68,0x3d,0x31,0x30,0x30,0x25,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x62,0x61,0x72,0x00,0x76,0x61,0x6c,
|
||||
0x75,0x65,0x00,0x30,0x00,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x5f,0x74,0x65,0x78,0x74,0x00,0x64,0x6f,0x6e,0x65,0x00,0x00,0x00,0x00,0x6c,0x69,0x73,0x74,0x5f,0x69,
|
||||
0x74,0x65,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,
|
||||
0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x65,
|
||||
0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,0x30,0x2c,0x77,0x3d,0x32,
|
||||
0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,0x6f,0x73,0x65,0x00,
|
||||
0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*5718*/
|
||||
0x00,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x65,0x6d,0x70,0x74,0x79,0x00,0x63,0x68,0x69,0x6c,0x64,0x72,
|
||||
0x65,0x6e,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x72,0x3d,
|
||||
0x31,0x2c,0x63,0x3d,0x30,0x2c,0x79,0x6d,0x3d,0x31,0x29,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,
|
||||
0x28,0x77,0x3d,0x33,0x30,0x25,0x29,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x75,0x73,0x74,0x6f,0x6d,0x00,
|
||||
0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x77,0x3d,0x37,0x30,0x25,0x29,0x00,0x74,0x69,0x70,
|
||||
0x73,0x00,0x63,0x75,0x73,0x74,0x6f,0x6d,0x20,0x6b,0x65,0x79,0x62,0x6f,0x61,0x72,0x64,0x00,0x74,0x65,
|
||||
0x78,0x74,0x00,0x00,0x6b,0x65,0x79,0x62,0x6f,0x61,0x72,0x64,0x00,0x6b,0x62,0x5f,0x66,0x6f,0x6f,0x00,
|
||||
0x63,0x61,0x6e,0x63,0x65,0x6c,0x61,0x62,0x6c,0x65,0x00,0x74,0x72,0x75,0x65,0x00,0x00,0x00,0x00,0x00,
|
||||
0x73,0x63,0x72,0x6f,0x6c,0x6c,0x5f,0x62,0x61,0x72,0x5f,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x0c,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,
|
||||
0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x72,0x69,0x67,0x68,0x74,0x2c,0x79,0x3d,0x30,0x2c,
|
||||
0x77,0x3d,0x31,0x32,0x2c,0x68,0x3d,0x31,0x30,0x30,0x25,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x62,0x61,
|
||||
0x72,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x30,0x00,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,
|
||||
0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,
|
||||
0x28,0x78,0x3d,0x63,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,
|
||||
0x30,0x2c,0x77,0x3d,0x32,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,
|
||||
0x6c,0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,};/*6043*/
|
||||
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -290,6 +290,16 @@ typedef enum _event_type_t {
|
||||
* 输入法提交输入的文本事件(im_commit_event_t)。
|
||||
*/
|
||||
EVT_IM_COMMIT,
|
||||
/**
|
||||
* @const EVT_IM_CLEAR
|
||||
* 清除编辑器内容(event_t)。
|
||||
*/
|
||||
EVT_IM_CLEAR,
|
||||
/**
|
||||
* @const EVT_IM_CANCEL
|
||||
* 取消编辑,恢复之前的内容(event_t)。
|
||||
*/
|
||||
EVT_IM_CANCEL,
|
||||
/**
|
||||
* @const EVT_IM_PREEDIT
|
||||
* 进入预编辑状态(event_t)。
|
||||
|
@ -2868,7 +2868,7 @@ static ret_t widget_set_parent_not_dirty(widget_t* widget) {
|
||||
|
||||
ret_t widget_invalidate(widget_t* widget, rect_t* r) {
|
||||
rect_t rself;
|
||||
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
||||
return_value_if_fail(widget != NULL && widget->vt != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (widget->dirty) {
|
||||
return RET_OK;
|
||||
|
@ -395,6 +395,12 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
#define WIDGET_PROP_READONLY "readonly"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_CANCELABLE
|
||||
* 是否可取消。
|
||||
*/
|
||||
#define WIDGET_PROP_CANCELABLE "cancelable"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_PASSWORD_VISIBLE
|
||||
* 密码是否可见。
|
||||
@ -1266,6 +1272,12 @@ typedef enum _window_closable_t {
|
||||
*/
|
||||
#define WIDGET_STATE_NORMAL "normal"
|
||||
|
||||
/**
|
||||
* @const WIDGET_STATE_CHANGED
|
||||
* 内容被修改的状态。
|
||||
*/
|
||||
#define WIDGET_STATE_CHANGED "changed"
|
||||
|
||||
/**
|
||||
* @const WIDGET_STATE_PRESSED
|
||||
* 指针按下状态。
|
||||
|
@ -142,6 +142,8 @@ static ret_t keyboard_set_active_page(widget_t* button, const char* name) {
|
||||
|
||||
#define STR_BACK "back"
|
||||
#define STR_CLOSE "close"
|
||||
#define STR_CLEAR "clear"
|
||||
#define STR_CANCEL "cancel"
|
||||
#define STR_RETURN "return"
|
||||
#define STR_ACTION "action"
|
||||
#define STR_KEY_SPACE "space"
|
||||
@ -202,7 +204,21 @@ static ret_t keyboard_on_button_click(void* ctx, event_t* e) {
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if (tk_str_eq(name, STR_CLEAR)) {
|
||||
event_t e = event_init(EVT_IM_CLEAR, NULL);
|
||||
input_method_dispatch_to_widget(im, &e);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if (tk_str_eq(name, STR_CANCEL)) {
|
||||
event_t e = event_init(EVT_IM_CANCEL, NULL);
|
||||
input_method_dispatch_to_widget(im, &e);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
if (tk_str_eq(name, STR_BACK)) {
|
||||
window_manager_back(window_manager());
|
||||
return RET_OK;
|
||||
|
@ -61,6 +61,8 @@ BEGIN_C_DECLS
|
||||
*| tab | tab键 |
|
||||
*| space | 空格键 |
|
||||
*| close | 关闭软键盘 |
|
||||
*| clear | 清除编辑器的内容 |
|
||||
*| cancel | 恢复编辑器的内容 |
|
||||
*| back | 关闭当前窗口 |
|
||||
*| back_to_home | 返回home窗口 |
|
||||
*| 前缀key: | 键值 |
|
||||
|
@ -47,6 +47,40 @@ static ret_t edit_auto_fix(widget_t* widget);
|
||||
static ret_t edit_update_status(widget_t* widget);
|
||||
static ret_t edit_select_all_async(const idle_info_t* info);
|
||||
|
||||
static ret_t edit_save_text(widget_t* widget) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (edit->cancelable) {
|
||||
wstr_set(&(edit->saved_text), widget->text.str);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t edit_rollback_text(widget_t* widget) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (edit->cancelable) {
|
||||
widget_set_text(widget, edit->saved_text.str);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t edit_commit_text(widget_t* widget) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (edit->cancelable) {
|
||||
wstr_set(&(edit->saved_text), widget->text.str);
|
||||
edit_update_status(widget);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t edit_dispatch_event(widget_t* widget, event_type_t type) {
|
||||
event_t evt = event_init(type, widget);
|
||||
widget_dispatch(widget, &evt);
|
||||
@ -381,16 +415,26 @@ static ret_t edit_auto_fix_default(widget_t* widget) {
|
||||
}
|
||||
|
||||
static ret_t edit_update_status(widget_t* widget) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
if (widget->text.size == 0) {
|
||||
if (widget->focused) {
|
||||
widget_set_state(widget, WIDGET_STATE_EMPTY_FOCUS);
|
||||
} else {
|
||||
widget_set_state(widget, WIDGET_STATE_EMPTY);
|
||||
}
|
||||
} else if (widget->focused) {
|
||||
widget_set_state(widget, WIDGET_STATE_FOCUSED);
|
||||
} else {
|
||||
widget_set_state(widget, WIDGET_STATE_NORMAL);
|
||||
if (edit->cancelable) {
|
||||
if(!wstr_equal(&(edit->saved_text), &(widget->text))) {
|
||||
widget_set_state(widget, WIDGET_STATE_CHANGED);
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (widget->focused) {
|
||||
widget_set_state(widget, WIDGET_STATE_FOCUSED);
|
||||
} else {
|
||||
widget_set_state(widget, WIDGET_STATE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
@ -683,12 +727,14 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
|
||||
}
|
||||
text_edit_unselect(edit->model);
|
||||
edit_dispatch_event(widget, EVT_VALUE_CHANGED);
|
||||
edit_commit_text(widget);
|
||||
break;
|
||||
}
|
||||
case EVT_FOCUS: {
|
||||
if (edit->open_im_when_focused) {
|
||||
edit_on_focused(widget);
|
||||
}
|
||||
edit_save_text(widget);
|
||||
break;
|
||||
}
|
||||
case EVT_WHEEL: {
|
||||
@ -714,6 +760,14 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
|
||||
widget_invalidate(widget, NULL);
|
||||
break;
|
||||
}
|
||||
case EVT_IM_CLEAR: {
|
||||
edit_clear(edit);
|
||||
break;
|
||||
}
|
||||
case EVT_IM_CANCEL: {
|
||||
edit_rollback_text(widget);
|
||||
break;
|
||||
}
|
||||
case EVT_IM_ACTION: {
|
||||
if (tk_str_eq(edit->action_text, ACTION_TEXT_DONE)) {
|
||||
input_method_request(input_method(), NULL);
|
||||
@ -791,6 +845,15 @@ ret_t edit_set_readonly(widget_t* widget, bool_t readonly) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t edit_set_cancelable(widget_t* widget, bool_t cancelable) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
edit->cancelable = cancelable;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t edit_set_auto_fix(widget_t* widget, bool_t auto_fix) {
|
||||
edit_t* edit = EDIT(widget);
|
||||
return_value_if_fail(edit != NULL, RET_BAD_PARAMS);
|
||||
@ -969,6 +1032,9 @@ ret_t edit_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_READONLY)) {
|
||||
value_set_bool(v, edit->readonly);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_CANCELABLE)) {
|
||||
value_set_bool(v, edit->cancelable);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_AUTO_FIX)) {
|
||||
value_set_bool(v, edit->auto_fix);
|
||||
return RET_OK;
|
||||
@ -1122,6 +1188,9 @@ ret_t edit_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_READONLY)) {
|
||||
edit->readonly = value_bool(v);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_CANCELABLE)) {
|
||||
edit->cancelable = value_bool(v);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_AUTO_FIX)) {
|
||||
edit->auto_fix = value_bool(v);
|
||||
return RET_OK;
|
||||
@ -1379,6 +1448,7 @@ ret_t edit_clear(edit_t* edit) {
|
||||
|
||||
widget->text.size = 0;
|
||||
text_edit_set_cursor(edit->model, 0xffffffff);
|
||||
edit_update_status(widget);
|
||||
|
||||
return widget_invalidate_force(widget, NULL);
|
||||
}
|
||||
@ -1449,6 +1519,7 @@ ret_t edit_on_destroy(widget_t* widget) {
|
||||
TKMEM_FREE(edit->tr_tips);
|
||||
TKMEM_FREE(edit->keyboard);
|
||||
TKMEM_FREE(edit->action_text);
|
||||
wstr_reset(&(edit->saved_text));
|
||||
text_edit_destroy(edit->model);
|
||||
|
||||
return RET_OK;
|
||||
@ -1470,6 +1541,7 @@ const char* const s_edit_properties[] = {WIDGET_PROP_MIN,
|
||||
WIDGET_PROP_STEP,
|
||||
WIDGET_PROP_INPUT_TYPE,
|
||||
WIDGET_PROP_READONLY,
|
||||
WIDGET_PROP_CANCELABLE,
|
||||
WIDGET_PROP_AUTO_FIX,
|
||||
WIDGET_PROP_MARGIN,
|
||||
WIDGET_PROP_LEFT_MARGIN,
|
||||
@ -1544,6 +1616,7 @@ widget_t* edit_create_ex(widget_t* parent, const widget_vtable_t* vt, xy_t x, xy
|
||||
ENSURE(edit->model != NULL);
|
||||
|
||||
widget_set_text(widget, L"");
|
||||
wstr_init(&(edit->saved_text), 0);
|
||||
edit_set_password_visible(widget, FALSE);
|
||||
edit_set_action_text(widget, ACTION_TEXT_DONE);
|
||||
|
||||
|
@ -220,12 +220,21 @@ typedef struct _edit_t {
|
||||
* 作为数值型编辑器时,一次增加和减少时的数值。
|
||||
*/
|
||||
double step;
|
||||
/**
|
||||
* @property {bool_t} cancelable
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 是否支持撤销编辑。如果为TRUE,在失去焦点之前可以撤销所有修改(恢复获得焦点之前的内容)。
|
||||
*
|
||||
* > * 1.一般配合keyboard的"cancel"按钮使用。
|
||||
* > * 2.为TRUE时,如果内容有变化,会设置编辑器的状态为changed,所以此时编辑器需要支持changed状态的style。
|
||||
*/
|
||||
bool_t cancelable;
|
||||
|
||||
/*private*/
|
||||
uint32_t idle_id;
|
||||
uint32_t timer_id;
|
||||
text_edit_t* model;
|
||||
|
||||
wstr_t saved_text;
|
||||
edit_inc_value_t inc_value;
|
||||
edit_dec_value_t dec_value;
|
||||
edit_fix_value_t fix_value;
|
||||
@ -360,6 +369,17 @@ ret_t edit_set_float_limit(widget_t* widget, double min, double max, double step
|
||||
*/
|
||||
ret_t edit_set_readonly(widget_t* widget, bool_t readonly);
|
||||
|
||||
/**
|
||||
* @method edit_set_cancelable
|
||||
* 设置编辑器是否为可撤销修改。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget widget对象。
|
||||
* @param {bool_t} cancelable 是否为可撤销修。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t edit_set_cancelable(widget_t* widget, bool_t cancelable);
|
||||
|
||||
/**
|
||||
* @method edit_set_auto_fix
|
||||
* 设置编辑器是否为自动改正。
|
||||
|
@ -165,6 +165,9 @@ TEST(Edit, basic) {
|
||||
|
||||
ASSERT_EQ(edit_set_readonly(b, TRUE), RET_OK);
|
||||
ASSERT_EQ(EDIT(b)->readonly, TRUE);
|
||||
|
||||
ASSERT_EQ(edit_set_cancelable(b, TRUE), RET_OK);
|
||||
ASSERT_EQ(EDIT(b)->cancelable, TRUE);
|
||||
|
||||
value_set_bool(&v1, FALSE);
|
||||
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_READONLY, &v1), RET_OK);
|
||||
|
@ -4994,6 +4994,14 @@
|
||||
"desc": "输入法提交输入的文本事件(im_commit_event_t)。",
|
||||
"name": "EVT_IM_COMMIT"
|
||||
},
|
||||
{
|
||||
"desc": "清除编辑器内容(event_t)。",
|
||||
"name": "EVT_IM_CLEAR"
|
||||
},
|
||||
{
|
||||
"desc": "取消编辑,恢复之前的内容(event_t)。",
|
||||
"name": "EVT_IM_CANCEL"
|
||||
},
|
||||
{
|
||||
"desc": "进入预编辑状态(event_t)。",
|
||||
"name": "EVT_IM_PREEDIT"
|
||||
@ -17495,6 +17503,10 @@
|
||||
"desc": "只读模式。",
|
||||
"name": "WIDGET_PROP_READONLY"
|
||||
},
|
||||
{
|
||||
"desc": "是否可取消。",
|
||||
"name": "WIDGET_PROP_CANCELABLE"
|
||||
},
|
||||
{
|
||||
"desc": "密码是否可见。",
|
||||
"name": "WIDGET_PROP_PASSWORD_VISIBLE"
|
||||
@ -18113,6 +18125,10 @@
|
||||
"desc": "正常状态。",
|
||||
"name": "WIDGET_STATE_NORMAL"
|
||||
},
|
||||
{
|
||||
"desc": "内容被修改的状态。",
|
||||
"name": "WIDGET_STATE_CHANGED"
|
||||
},
|
||||
{
|
||||
"desc": "指针按下状态。",
|
||||
"name": "WIDGET_STATE_PRESSED"
|
||||
@ -23247,8 +23263,8 @@
|
||||
},
|
||||
{
|
||||
"type": "const char*",
|
||||
"name": "",
|
||||
"desc": "。"
|
||||
"name": "from_str",
|
||||
"desc": "源字符串。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
@ -23268,7 +23284,7 @@
|
||||
{
|
||||
"type": "uint32_t",
|
||||
"name": "to_size",
|
||||
"desc": "目标字符串的长度。"
|
||||
"desc": "目标字符串的最大长度。"
|
||||
}
|
||||
],
|
||||
"annotation": {
|
||||
@ -23285,8 +23301,8 @@
|
||||
"params": [
|
||||
{
|
||||
"type": "const char*",
|
||||
"name": "",
|
||||
"desc": "。"
|
||||
"name": "from_str",
|
||||
"desc": "源字符串(utf8)。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
@ -23295,13 +23311,13 @@
|
||||
},
|
||||
{
|
||||
"type": "const char*",
|
||||
"name": "",
|
||||
"desc": "。"
|
||||
"name": "to_str",
|
||||
"desc": "目标字符串(gbk)。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
"name": "to_size",
|
||||
"desc": "目标字符串的长度。"
|
||||
"desc": "目标字符串的最大长度。"
|
||||
}
|
||||
],
|
||||
"annotation": {
|
||||
@ -23318,8 +23334,8 @@
|
||||
"params": [
|
||||
{
|
||||
"type": "const char*",
|
||||
"name": "",
|
||||
"desc": "。"
|
||||
"name": "from_str",
|
||||
"desc": "源字符串(gbk)。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
@ -23334,7 +23350,7 @@
|
||||
{
|
||||
"type": "uint32_t",
|
||||
"name": "to_size",
|
||||
"desc": "目标字符串的长度。"
|
||||
"desc": "目标字符串的最大长度。"
|
||||
}
|
||||
],
|
||||
"annotation": {
|
||||
@ -41529,6 +41545,29 @@
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "widget_t*",
|
||||
"name": "widget",
|
||||
"desc": "widget对象。"
|
||||
},
|
||||
{
|
||||
"type": "bool_t",
|
||||
"name": "cancelable",
|
||||
"desc": "是否为可撤销修。"
|
||||
}
|
||||
],
|
||||
"annotation": {
|
||||
"scriptable": true
|
||||
},
|
||||
"desc": "设置编辑器是否为可撤销修改。",
|
||||
"name": "edit_set_cancelable",
|
||||
"return": {
|
||||
"type": "ret_t",
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
@ -42142,6 +42181,19 @@
|
||||
"design": true,
|
||||
"scriptable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "cancelable",
|
||||
"desc": "是否支持撤销编辑。如果为TRUE,在失去焦点之前可以撤销所有修改(恢复获得焦点之前的内容)。\n\n> * 1.一般配合keyboard的\"cancel\"按钮使用。\n> * 2.为TRUE时,如果内容有变化,会设置编辑器的状态为changed,所以此时编辑器需要支持changed状态的style。",
|
||||
"type": "bool_t",
|
||||
"annotation": {
|
||||
"set_prop": true,
|
||||
"get_prop": true,
|
||||
"readable": true,
|
||||
"persitent": true,
|
||||
"design": true,
|
||||
"scriptable": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": "widgets/edit.h",
|
||||
@ -57229,7 +57281,7 @@
|
||||
"events": [],
|
||||
"properties": [],
|
||||
"header": "keyboard/keyboard.h",
|
||||
"desc": "软键盘。\n\n软键盘是一个特殊的窗口,由编辑器通过输入法自动打开和关闭。\n\n这里介绍一下定制软键盘的方法:\n\n编辑器输入类型和软键盘UI资源文件的对应关系:\n\n| 输入类型 | 软键盘UI资源文件|\n|----------------|:---------------:|\n| INPUT\\_PHONE | kb\\_phone.xml |\n| INPUT\\_INT | kb\\_int.xml |\n| INPUT\\_FLOAT | kb\\_float.xml |\n| INPUT\\_UINT | kb\\_uint.xml |\n| INPUT\\_UFLOAT | kb\\_ufloat.xml |\n| INPUT\\_HEX | kb\\_hex.xml |\n| INPUT\\_EMAIL | kb\\_ascii.xml |\n| INPUT\\_PASSWORD | kb\\_ascii.xml |\n| INPUT\\_CUSTOM | 使用自定义的键盘 |\n| 其它 | kb\\_default.xml |\n\nkeyboard中按钮子控件的名称有些特殊要求:\n\n| 名称 | 功能 |\n|----------------|:---------------:|\n| return | 回车键 |\n| action | 定制按钮 |\n| backspace | 删除键 |\n| tab | tab键 |\n| space | 空格键 |\n| close | 关闭软键盘 |\n| back | 关闭当前窗口 |\n| back_to_home | 返回home窗口 |\n| 前缀key: | 键值 |\n| 前缀hard_key: | 模拟物理键盘 |\n| 前缀page: | 切换到页面 |\n| 前缀opt: | 多个字符选择一个,点击切换到下一个,超时提交字符(用于实现九宫格输入) |\n\n示例:\n\n* 按键\"a\",提交输入法处理。\n\n```xml\n<button repeat=\"300\" name=\"key:a\" text=\"a\"/>\n```\n\n* 字符\"a\",直接提交到编辑器。\n\n```xml\n<button repeat=\"300\" name=\"a\" text=\"a\"/>\n```\n\n* 模拟物理键盘数字\"1\",触发key down/up事件(可以用来选择候选字)。\n\n```xml\n<button repeat=\"300\" name=\"hard_key:1\" text=\"1\"/>\n```\n\n* 九宫格输入\n\n```xml\n<button repeat=\"300\" name=\"opt:._@/#\" text=\"._@/#\"/>\n<button repeat=\"300\" name=\"opt:abc\" text=\"abc\"/>\n<button repeat=\"300\" name=\"opt:def\" text=\"def\"/>\n```\n\n\n* 输入语言切换\n\n有的输入法,同时支持输入多种语言。\n比如T9,可以同时支持中文和英文输入,配合软键盘随时切换输入的语言。\n\n可以在pages的页面里指定lang属性,切换到该页面时会设置输入法的语言。如:\n\n```xml\n<pages x=\"0\" y=\"bottom\" w=\"100%\" h=\"-28\" active=\"2\">\n<view name=\"lower\" lang=\"en_us\"\nx=\"0\" y=\"0\" w=\"100%\" h=\"100%\" children_layout=\"default(r=4,c=4,s=2,m=2)\">\n...\n</view>\n<view name=\"chinese\" lang=\"zh_cn\"\nx=\"0\" y=\"0\" w=\"100%\" h=\"100%\" children_layout=\"default(r=4,c=4,s=2,m=2)\">\n...\n</view>\n</pages>\n```\n\n> 更多用法请参考:\n[kb_default](https://github.com/zlgopen/awtk/blob/master/design/default/ui/kb_default.xml)",
|
||||
"desc": "软键盘。\n\n软键盘是一个特殊的窗口,由编辑器通过输入法自动打开和关闭。\n\n这里介绍一下定制软键盘的方法:\n\n编辑器输入类型和软键盘UI资源文件的对应关系:\n\n| 输入类型 | 软键盘UI资源文件|\n|----------------|:---------------:|\n| INPUT\\_PHONE | kb\\_phone.xml |\n| INPUT\\_INT | kb\\_int.xml |\n| INPUT\\_FLOAT | kb\\_float.xml |\n| INPUT\\_UINT | kb\\_uint.xml |\n| INPUT\\_UFLOAT | kb\\_ufloat.xml |\n| INPUT\\_HEX | kb\\_hex.xml |\n| INPUT\\_EMAIL | kb\\_ascii.xml |\n| INPUT\\_PASSWORD | kb\\_ascii.xml |\n| INPUT\\_CUSTOM | 使用自定义的键盘 |\n| 其它 | kb\\_default.xml |\n\nkeyboard中按钮子控件的名称有些特殊要求:\n\n| 名称 | 功能 |\n|----------------|:---------------:|\n| return | 回车键 |\n| action | 定制按钮 |\n| backspace | 删除键 |\n| tab | tab键 |\n| space | 空格键 |\n| close | 关闭软键盘 |\n| clear | 清除编辑器的内容 |\n| cancel | 恢复编辑器的内容 |\n| back | 关闭当前窗口 |\n| back_to_home | 返回home窗口 |\n| 前缀key: | 键值 |\n| 前缀hard_key: | 模拟物理键盘 |\n| 前缀page: | 切换到页面 |\n| 前缀opt: | 多个字符选择一个,点击切换到下一个,超时提交字符(用于实现九宫格输入) |\n\n示例:\n\n* 按键\"a\",提交输入法处理。\n\n```xml\n<button repeat=\"300\" name=\"key:a\" text=\"a\"/>\n```\n\n* 字符\"a\",直接提交到编辑器。\n\n```xml\n<button repeat=\"300\" name=\"a\" text=\"a\"/>\n```\n\n* 模拟物理键盘数字\"1\",触发key down/up事件(可以用来选择候选字)。\n\n```xml\n<button repeat=\"300\" name=\"hard_key:1\" text=\"1\"/>\n```\n\n* 九宫格输入\n\n```xml\n<button repeat=\"300\" name=\"opt:._@/#\" text=\"._@/#\"/>\n<button repeat=\"300\" name=\"opt:abc\" text=\"abc\"/>\n<button repeat=\"300\" name=\"opt:def\" text=\"def\"/>\n```\n\n\n* 输入语言切换\n\n有的输入法,同时支持输入多种语言。\n比如T9,可以同时支持中文和英文输入,配合软键盘随时切换输入的语言。\n\n可以在pages的页面里指定lang属性,切换到该页面时会设置输入法的语言。如:\n\n```xml\n<pages x=\"0\" y=\"bottom\" w=\"100%\" h=\"-28\" active=\"2\">\n<view name=\"lower\" lang=\"en_us\"\nx=\"0\" y=\"0\" w=\"100%\" h=\"100%\" children_layout=\"default(r=4,c=4,s=2,m=2)\">\n...\n</view>\n<view name=\"chinese\" lang=\"zh_cn\"\nx=\"0\" y=\"0\" w=\"100%\" h=\"100%\" children_layout=\"default(r=4,c=4,s=2,m=2)\">\n...\n</view>\n</pages>\n```\n\n> 更多用法请参考:\n[kb_default](https://github.com/zlgopen/awtk/blob/master/design/default/ui/kb_default.xml)",
|
||||
"name": "keyboard_t",
|
||||
"parent": "window_base_t",
|
||||
"annotation": {
|
||||
|
Loading…
Reference in New Issue
Block a user