evas_textblock: emit change event on markup_set

Markup_set will emit change events, if user set empty string.
This Change is related to D10985, where markup_prepend will not emit events if empty string was added

Reviewed-by: Al Poole <netstar@gmail.com>
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11020
This commit is contained in:
Ali Alzyod 2020-01-07 08:32:19 +00:00 committed by Marcel Hollerbach
parent 3249b53d1c
commit d6649ad80a
2 changed files with 35 additions and 0 deletions

View File

@ -8503,6 +8503,15 @@ _evas_object_textblock_text_markup_set(Eo *eo_obj, Efl_Canvas_Textblock_Data *o,
evas_textblock_cursor_paragraph_first(o->cursor);
evas_object_textblock_text_markup_prepend(o->cursor, text);
/*If there was no text markup_prepend will not call change function
So we will call it inside markup_set*/
if (!text || !*text)
{
efl_event_callback_call(eo_obj, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, NULL);
_evas_textblock_changed(o, eo_obj);
}
efl_event_freeze(eo_obj);
/* Point all the cursors to the starrt */
{

View File

@ -4942,6 +4942,31 @@ EFL_START_TEST(efl_text_style)
{
START_EFL_CANVAS_TEXTBLOCK_TEST();
int changed_emit = 0;
efl_event_callback_add(txt, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, _increment_int_changed, &changed_emit);
efl_text_set(txt, "Hello");
ck_assert_int_eq(changed_emit, 1);
efl_text_set(txt, "");
ck_assert_int_eq(changed_emit, 2);
efl_text_set(txt, "");
ck_assert_int_eq(changed_emit, 2);
changed_emit = 0;
efl_text_markup_set(txt, "&quot;Hello&quot;");
ck_assert_int_eq(changed_emit, 1);
efl_text_markup_set(txt, "");
ck_assert_int_eq(changed_emit, 2);
efl_text_markup_set(txt, "");
ck_assert_int_eq(changed_emit, 2);
END_EFL_CANVAS_TEXTBLOCK_TEST();
}
EFL_END_TEST
EFL_START_TEST(efl_text_markup)
{
START_EFL_CANVAS_TEXTBLOCK_TEST();
efl_text_underline_type_set(txt, EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE);
ck_assert_int_eq(efl_text_underline_type_get(txt), EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE);
efl_text_underline_type_set(txt, EFL_TEXT_STYLE_UNDERLINE_TYPE_SINGLE);
@ -4992,5 +5017,6 @@ void evas_test_textblock(TCase *tc)
tcase_add_test(tc, efl_text_font);
tcase_add_test(tc, efl_canvas_textblock_style);
tcase_add_test(tc, efl_text_style);
tcase_add_test(tc, efl_text_markup);
}