jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=22ed5794307eaf9a2b280adc6a1c7377fefd74ac

commit 22ed5794307eaf9a2b280adc6a1c7377fefd74ac
Author: Youngbok Shin <youngb.s...@samsung.com>
Date:   Fri Jun 9 14:19:57 2017 +0900

    elementary entry: update focus state when editable state is changed
    
    Summary:
    To recieve keyboard events, the entry_edje should have Evas focus.
    But, if a non editable Entry widget takes focus, it can't recieve
    keyboard events even if it becomes editable after taking focus.
    So, elm_entry_editable_set() function should update Entry's focus state.
    @fix
    
    Test Plan:
    The code of elementary_test - entry is modified to test this issue.
    Please, check the issue with the following steps.
    
    1. Run "elementary_test entry"
    2. Click "Unfocus" button to make entry to "unfocused" state.
    3. Click "Edit" button to make entry to non-editable mode.
    4. Click "Focus" button to make entry to "focused" state.
    5. Click "Edit" button to make entry to editable mode.
    6. See a cursor is blinking in entry.
       => But, you can't edit text without this patch.
    
    Reviewers: raster, herdsman, cedric, jpeg, woohyun
    
    Differential Revision: https://phab.enlightenment.org/D4858
---
 src/bin/elementary/test_entry.c | 46 +++++++++++++++++++++++++++++++++++++++++
 src/lib/elementary/elm_entry.c  | 15 +++++++++-----
 2 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/src/bin/elementary/test_entry.c b/src/bin/elementary/test_entry.c
index 77e2fa88a1..9b2275f9d8 100644
--- a/src/bin/elementary/test_entry.c
+++ b/src/bin/elementary/test_entry.c
@@ -86,6 +86,20 @@ my_entry_bt_7(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UN
 }
 
 static void
+my_entry_bt_8(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
+{
+   Evas_Object *en = data;
+   elm_object_focus_set(en, EINA_TRUE);
+}
+
+static void
+my_entry_bt_9(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
+{
+   Evas_Object *en = data;
+   elm_object_focus_set(en, EINA_FALSE);
+}
+
+static void
 changed_cb1(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
    Evas_Object *ck = data;
@@ -114,6 +128,18 @@ entry_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, 
void *event_info EINA
    
 }
 
+static void
+entry_focused_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
+{
+   printf("Entry 'focused' callback called\n");
+}
+
+static void
+entry_unfocused_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
+{
+   printf("Entry 'unfocused' callback called\n");
+}
+
 void
 test_entry(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
 {
@@ -166,6 +192,8 @@ test_entry(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_inf
    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_smart_callback_add(en, "changed", entry_changed_cb, "changed");
    evas_object_smart_callback_add(en, "changed,user", entry_changed_cb, 
"changed,user");
+   evas_object_smart_callback_add(en, "focused", entry_focused_cb, NULL);
+   evas_object_smart_callback_add(en, "unfocused", entry_unfocused_cb, NULL);
    elm_box_pack_end(bx, en);
    evas_object_show(en);
    elm_object_focus_set(en, EINA_TRUE);
@@ -238,6 +266,24 @@ test_entry(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_inf
    elm_object_focus_allow_set(bt, EINA_FALSE);
    evas_object_show(bt);
 
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Focus");
+   evas_object_smart_callback_add(bt, "clicked", my_entry_bt_8, en);
+   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
+   elm_box_pack_end(bx2, bt);
+   elm_object_focus_allow_set(bt, EINA_FALSE);
+   evas_object_show(bt);
+
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Unfocus");
+   evas_object_smart_callback_add(bt, "clicked", my_entry_bt_9, en);
+   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
+   elm_box_pack_end(bx2, bt);
+   elm_object_focus_allow_set(bt, EINA_FALSE);
+   evas_object_show(bt);
+
    bx3 = elm_box_add(win);
    elm_box_horizontal_set(bx3, EINA_TRUE);
    evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0);
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index e5f9eec798..c10bf580c6 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -1228,19 +1228,17 @@ _return_key_enabled_check(Evas_Object *obj)
    elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
 }
 
-EOLIAN static Eina_Bool
-_elm_entry_elm_widget_on_focus(Eo *obj, Elm_Entry_Data *sd, Elm_Object_Item 
*item EINA_UNUSED)
+static void
+_elm_entry_focus_update(Eo *obj, Elm_Entry_Data *sd)
 {
    Evas_Object *top;
    Eina_Bool top_is_win = EINA_FALSE;
 
-   if (!sd->editable) return EINA_FALSE;
-
    top = elm_widget_top_get(obj);
    if (top && efl_isa(top, EFL_UI_WIN_CLASS))
      top_is_win = EINA_TRUE;
 
-   if (elm_widget_focus_get(obj))
+   if (elm_widget_focus_get(obj) && sd->editable)
      {
         evas_object_focus_set(sd->entry_edje, EINA_TRUE);
         edje_object_signal_emit(sd->entry_edje, "elm,action,focus", "elm");
@@ -1282,6 +1280,12 @@ _elm_entry_elm_widget_on_focus(Eo *obj, Elm_Entry_Data 
*sd, Elm_Object_Item *ite
           }
         edje_object_signal_emit(sd->scr_edje, "validation,default", "elm");
      }
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_on_focus(Eo *obj, Elm_Entry_Data *sd, Elm_Object_Item 
*item EINA_UNUSED)
+{
+   _elm_entry_focus_update(obj, sd);
 
    return EINA_TRUE;
 }
@@ -4240,6 +4244,7 @@ _elm_entry_editable_set(Eo *obj, Elm_Entry_Data *sd, 
Eina_Bool editable)
    if (sd->editable == editable) return;
    sd->editable = editable;
    elm_obj_widget_theme_apply(obj);
+   _elm_entry_focus_update(obj, sd);
 
    elm_drop_target_del(obj, sd->drop_format,
                        _dnd_enter_cb, NULL,

-- 


Reply via email to