mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
unselect text when edit lost focus
This commit is contained in:
parent
6e98eebf76
commit
53729d7a9f
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
* 2019/09/03
|
||||
* edit/mledit失去焦点时,unselect当前选中的文本。
|
||||
|
||||
* 2019/09/02
|
||||
* merge patch issue #224(感谢陈谭提供补丁)。
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
* 设置光标位置。
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user