mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
fix cursor when set text for edit
This commit is contained in:
parent
3578b540b6
commit
5e2630e6ad
@ -525,11 +525,13 @@ ret_t edit_on_event(widget_t* widget, event_t* e) {
|
||||
prop_change_event_t* evt = (prop_change_event_t*)e;
|
||||
if (tk_str_eq(evt->name, WIDGET_PROP_TEXT) || tk_str_eq(evt->name, WIDGET_PROP_VALUE)) {
|
||||
edit_update_status(widget);
|
||||
text_edit_set_cursor(edit->model, 0xffffffff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EVT_VALUE_CHANGING: {
|
||||
edit_update_status(widget);
|
||||
text_edit_set_cursor(edit->model, 0xffffffff);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -44,6 +44,18 @@ TEST(Edit, int) {
|
||||
widget_destroy(b);
|
||||
}
|
||||
|
||||
TEST(Edit, set_text) {
|
||||
text_edit_state_t state;
|
||||
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
|
||||
widget_set_text_utf8(b, "hello");
|
||||
|
||||
ASSERT_EQ(text_edit_get_state(EDIT(b)->model, &state), RET_OK);
|
||||
ASSERT_EQ(state.cursor, 5);
|
||||
|
||||
widget_destroy(b);
|
||||
}
|
||||
|
||||
|
||||
TEST(Edit, inputable) {
|
||||
widget_t* b = edit_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(b->vt->inputable, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user