diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 48e7b3b6ec..54e431190c 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -10786,7 +10786,15 @@ evas_textblock_cursor_char_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, E { Evas_Object_Textblock_Format_Item *fi; fi = _ITEM_FORMAT(it); - cur->pos = fi->parent.text_pos; + /* Lets keep cur position half way for easy positioning */ + if (x > (ln->x + it->x + (it->adv / 2))) + { + cur->pos = fi->parent.text_pos + 1; + } + else + { + cur->pos = fi->parent.text_pos; + } cur->node = found_par->text_node; return EINA_TRUE; } diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index 467e1644e6..528e64016c 100644 --- a/src/tests/evas/evas_test_textblock.c +++ b/src/tests/evas/evas_test_textblock.c @@ -1693,7 +1693,7 @@ END_TEST /* Testing items */ START_TEST(evas_textblock_items) { - Evas_Coord w, h, w2, h2, nw, nh, ih; + Evas_Coord x, y, w, h, w2, h2, nw, nh, ih; START_TB_TEST(); const char *buf = "This is an ."; @@ -1798,6 +1798,18 @@ START_TEST(evas_textblock_items) if (evas_textblock_cursor_format_item_geometry_get(cur, NULL, NULL, &w, &h)) fail_if((w != 64) || (h != 64)); + /* Test char coordinate for item at middle position of the item to decide cursor position, + * it means when char coordinate exceeds the half width of the item then only + * cursor position is changed. */ + buf = "."; + evas_object_textblock_text_markup_set(tb, buf); + evas_textblock_cursor_format_item_geometry_get(cur, &x, &y, &w, NULL); + evas_textblock_cursor_char_coord_set(cur, x + (w / 2) + 1, y); + fail_if(evas_textblock_cursor_pos_get(cur) != 1); + /* Test small increment in x and cursor position will be same */ + evas_textblock_cursor_char_coord_set(cur, x + 10, y); + fail_if(evas_textblock_cursor_pos_get(cur) != 0); + /* FIXME: Also verify x,y positions of the item. */ /* FIXME We need some item tests that involve line wrapping that make the