unselect text when edit lost focus

This commit is contained in:
lixianjing 2019-09-03 11:17:07 +08:00
parent 6e98eebf76
commit 53729d7a9f
5 changed files with 25 additions and 1 deletions

View File

@ -1,4 +1,7 @@
# 最新动态
* 2019/09/03
* edit/mledit失去焦点时unselect当前选中的文本。
* 2019/09/02
* merge patch issue #224(感谢陈谭提供补丁)。

View File

@ -1082,7 +1082,17 @@ ret_t text_edit_set_select(text_edit_t* text_edit, uint32_t start, uint32_t end)
impl->state.select_start = start;
impl->state.select_end = tk_min(end, text_edit->widget->text.size);
;
text_edit_layout(text_edit);
return RET_OK;
}
ret_t text_edit_unselect(text_edit_t* text_edit) {
DECL_IMPL(text_edit);
return_value_if_fail(text_edit != NULL, RET_BAD_PARAMS);
impl->state.select_end = impl->state.select_start;
text_edit_layout(text_edit);

View File

@ -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_unselect
*
* @param {text_edit_t*} text_edit text_edit对象
*
* @return {ret_t} RET_OK表示成功
*/
ret_t text_edit_unselect(text_edit_t* text_edit);
/**
* @method text_edit_set_cursor
*

View File

@ -389,6 +389,7 @@ static ret_t mledit_on_event(widget_t* widget, event_t* e) {
input_method_request(input_method(), NULL);
mledit_update_status(widget);
text_edit_unselect(mledit->model);
mledit_dispatch_event(widget, EVT_VALUE_CHANGED);
break;
}

View File

@ -522,6 +522,7 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
widget_set_state(widget, WIDGET_STATE_ERROR);
}
}
text_edit_unselect(edit->model);
edit_dispatch_event(widget, EVT_VALUE_CHANGED);
break;
}