fix cursor when set text for edit

This commit is contained in:
lixianjing 2019-06-28 01:42:17 -07:00
parent 3578b540b6
commit 5e2630e6ad
2 changed files with 14 additions and 0 deletions

View File

@ -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:

View File

@ -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);