summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora.srour <a.srour@samsung.com>2020-01-16 17:53:36 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-01-16 17:53:36 +0900
commit05bb02cbb021e97bbb4caf21af756ee15f144e9d (patch)
treebada50df5f799b95d9017d42f5937b9be1f6b4ab
parent3a4c5cf6a5f36dcdf27b2f2426d8e955a68e6d9e (diff)
Efl.Ui.Textbox: Fix Ctrl+Backspace & Ctrl+Delete keys
Summary: This should fix the behaviour of Ctrl+Backspace & Ctrl+Delete key down on `Efl.Ui.Textbox`. Also added two tests for it. Reviewers: woohyun, ali.alzyod, cedric, bu5hm4n Reviewed By: woohyun Subscribers: ProhtMeyhet, stefan_schmidt, segfaultxavi, bu5hm4n, #committers, #reviewers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11040
-rw-r--r--src/lib/elementary/efl_ui_internal_text_interactive.c4
-rw-r--r--src/tests/elementary/efl_ui_test_text.c38
2 files changed, 40 insertions, 2 deletions
diff --git a/src/lib/elementary/efl_ui_internal_text_interactive.c b/src/lib/elementary/efl_ui_internal_text_interactive.c
index 3851aa82a1..8e1ad98c6a 100644
--- a/src/lib/elementary/efl_ui_internal_text_interactive.c
+++ b/src/lib/elementary/efl_ui_internal_text_interactive.c
@@ -1215,7 +1215,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1215 // del to start of previous word 1215 // del to start of previous word
1216 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj); 1216 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj);
1217 1217
1218 _cur_pos_copy(tc, cur); 1218 _cur_pos_copy(cur, tc);
1219 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_PREV); 1219 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_PREV);
1220 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START); 1220 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_START);
1221 1221
@@ -1250,7 +1250,7 @@ _key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void
1250 // del to end of next word 1250 // del to end of next word
1251 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj); 1251 Efl_Text_Cursor *tc = efl_canvas_textblock_cursor_create(obj);
1252 1252
1253 _cur_pos_copy(tc, cur); 1253 _cur_pos_copy(cur, tc);
1254 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END); 1254 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_WORD_END);
1255 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_NEXT); 1255 efl_text_cursor_move(cur, EFL_TEXT_CURSOR_MOVE_TYPE_CHAR_NEXT);
1256 1256
diff --git a/src/tests/elementary/efl_ui_test_text.c b/src/tests/elementary/efl_ui_test_text.c
index 49ba50d91d..a49c7e7cc9 100644
--- a/src/tests/elementary/efl_ui_test_text.c
+++ b/src/tests/elementary/efl_ui_test_text.c
@@ -178,6 +178,43 @@ EFL_START_TEST(text_change_event)
178} 178}
179EFL_END_TEST 179EFL_END_TEST
180 180
181EFL_START_TEST(text_keys_handler)
182{
183 Eo *txt;
184 Eo *win = win_add();
185
186 txt = efl_add(EFL_UI_TEXTBOX_CLASS, win);
187 efl_gfx_entity_size_set(txt, EINA_SIZE2D(300, 300));
188 efl_text_set(txt, "Hello");
189
190 efl_gfx_entity_visible_set(txt, EINA_TRUE);
191 Evas *e = evas_object_evas_get(txt);
192 efl_ui_focus_util_focus(txt);
193
194 efl_text_cursor_move(efl_text_interactive_main_cursor_get(txt), EFL_TEXT_CURSOR_MOVE_TYPE_LAST);
195 evas_key_modifier_on(e, "Control");
196 evas_event_feed_key_down(e, "BackSpace", "BackSpace", "\b", "\b", time(NULL), NULL);
197 ecore_main_loop_iterate();
198 ck_assert_str_eq(efl_text_get(txt),"");
199 ck_assert_int_eq(efl_text_cursor_position_get(efl_text_interactive_main_cursor_get(txt)), 0);
200 evas_event_feed_key_up(e, "BackSpace", "BackSpace", "\b", "\b", time(NULL), NULL);
201 ecore_main_loop_iterate();
202
203 efl_text_set(txt, "Hello");
204 efl_text_cursor_position_set(efl_text_interactive_main_cursor_get(txt), 0);
205 evas_key_modifier_on(e, "Control");
206 evas_event_feed_key_down(e, "Delete", "Delete", "\177", "\177", time(NULL), NULL);
207 ecore_main_loop_iterate();
208 ck_assert_str_eq(efl_text_get(txt),"");
209 ck_assert_int_eq(efl_text_cursor_position_get(efl_text_interactive_main_cursor_get(txt)), 0);
210 evas_event_feed_key_up(e, "Delete", "Delete", "\177", "\177", time(NULL), NULL);
211 ecore_main_loop_iterate();
212
213 efl_del(txt);
214 efl_del(win);
215}
216EFL_END_TEST
217
181void efl_ui_test_text(TCase *tc) 218void efl_ui_test_text(TCase *tc)
182{ 219{
183 tcase_add_test(tc, text_cnp); 220 tcase_add_test(tc, text_cnp);
@@ -186,4 +223,5 @@ void efl_ui_test_text(TCase *tc)
186 tcase_add_test(tc, text_user_change); 223 tcase_add_test(tc, text_user_change);
187 tcase_add_test(tc, text_scroll_mode); 224 tcase_add_test(tc, text_scroll_mode);
188 tcase_add_test(tc, text_change_event); 225 tcase_add_test(tc, text_change_event);
226 tcase_add_test(tc, text_keys_handler);
189} 227}