Hello.

Whenever the theme (edj) is changed in entry, the cursor position in entry
is reset
because elm_entry does not save the cursor position in the entry.

This patch is for keeping the cursor position in entry regardless of
changing theme (edj).
It will save the cursor position in entry and set the cursor position again
after changing theme.

Would you please review this patch?

Index: elm_entry.c
===================================================================
--- elm_entry.c (revision 57787)
+++ elm_entry.c (working copy)
@@ -136,6 +136,7 @@ struct _Widget_Data
    Eina_Bool can_write : 1;
    Eina_Bool autosave : 1;
    Eina_Bool textonly : 1;
+   int cursor_pos;
 };
 
 struct _Elm_Entry_Context_Menu_Item
@@ -545,6 +546,9 @@ _theme_hook(Evas_Object *obj)
    eina_stringshare_del(t);
    if (elm_widget_disabled_get(obj))
       edje_object_signal_emit(wd->ent, "elm,state,disabled", "elm");
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+     edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    edje_object_message_signal_process(wd->ent);
    edje_object_scale_set(wd->ent, elm_widget_scale_get(obj) * 
_elm_config->scale);
    _sizing_eval(obj);
@@ -1181,6 +1185,7 @@ _signal_cursor_changed(void *data, Evas_Object *ob
    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
    edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text",
                                              &cx, &cy, &cw, &ch);
+   wd->cursor_pos = edje_object_part_text_cursor_pos_get(wd->ent, "elm.text", 
EDJE_CURSOR_MAIN);
    if (!wd->deferred_recalc_job)
      elm_widget_show_region_set(data, cx, cy, cw, ch);
    else
@@ -1625,6 +1630,9 @@ elm_entry_single_line_set(Evas_Object *obj, Eina_B
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), 
elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+     edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    _sizing_eval(obj);
 }
 
@@ -1672,10 +1680,12 @@ elm_entry_password_set(Evas_Object *obj, Eina_Bool
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), 
elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+     edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    _sizing_eval(obj);
 }
 
-
 /**
  * This returns whether password mode is enabled.
  * See also elm_entry_password_set().
@@ -1850,6 +1860,9 @@ elm_entry_line_wrap_set(Evas_Object *obj, Eina_Boo
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), 
elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+     edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    _sizing_eval(obj);
 }
 
@@ -1880,6 +1893,9 @@ elm_entry_line_char_wrap_set(Evas_Object *obj, Ein
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), 
elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+      edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    _sizing_eval(obj);
 }
 
@@ -1905,6 +1921,9 @@ elm_entry_editable_set(Evas_Object *obj, Eina_Bool
    _elm_theme_object_set(obj, wd->ent, "entry", _getbase(obj), 
elm_widget_style_get(obj));
    elm_entry_entry_set(obj, t);
    eina_stringshare_del(t);
+   elm_entry_cursor_pos_set(obj, wd->cursor_pos);
+   if (elm_widget_focus_get(obj))
+     edje_object_signal_emit(wd->ent, "elm,action,focus", "elm");
    _sizing_eval(obj);
 
 #ifdef HAVE_ELEMENTARY_X
@@ -2238,6 +2257,7 @@ elm_entry_cursor_pos_set(Evas_Object *obj, int pos
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
    edje_object_part_text_cursor_pos_set(wd->ent, "elm.text", EDJE_CURSOR_MAIN, 
pos);
+   edje_object_message_signal_process(wd->ent);
 }
 
 /**

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to