mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 12:08:16 +08:00
edit select all when get focus
This commit is contained in:
parent
f5cf240a84
commit
f01a3d070e
@ -1103,6 +1103,12 @@ ret_t text_edit_set_select(text_edit_t* text_edit, uint32_t start, uint32_t end)
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t text_edit_select_all(text_edit_t* text_edit) {
|
||||
return_value_if_fail(text_edit != NULL, RET_BAD_PARAMS);
|
||||
|
||||
return text_edit_set_select(text_edit, 0, text_edit->widget->text.size);
|
||||
}
|
||||
|
||||
ret_t text_edit_unselect(text_edit_t* text_edit) {
|
||||
DECL_IMPL(text_edit);
|
||||
return_value_if_fail(text_edit != NULL, RET_BAD_PARAMS);
|
||||
|
@ -152,6 +152,15 @@ ret_t text_edit_key_down(text_edit_t* text_edit, key_event_t* evt);
|
||||
*/
|
||||
ret_t text_edit_set_select(text_edit_t* text_edit, uint32_t start, uint32_t end);
|
||||
|
||||
/**
|
||||
* @method text_edit_select_all
|
||||
* 全选。
|
||||
* @param {text_edit_t*} text_edit text_edit对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t text_edit_select_all(text_edit_t* text_edit);
|
||||
|
||||
/**
|
||||
* @method text_edit_unselect
|
||||
* 取消选择。
|
||||
|
@ -454,6 +454,13 @@ static ret_t edit_on_key_down(widget_t* widget, key_event_t* e) {
|
||||
return RET_STOP;
|
||||
}
|
||||
|
||||
static ret_t edit_select_all_async(const idle_info_t* info) {
|
||||
edit_t* edit = EDIT(info->ctx);
|
||||
text_edit_select_all(edit->model);
|
||||
|
||||
return RET_REMOVE;
|
||||
}
|
||||
|
||||
ret_t edit_on_event(widget_t* widget, event_t* e) {
|
||||
ret_t ret = RET_OK;
|
||||
uint32_t type = e->type;
|
||||
@ -534,6 +541,7 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
|
||||
|
||||
if (widget->target == NULL) {
|
||||
edit_request_input_method(widget);
|
||||
idle_add(edit_select_all_async, edit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user