elm/entry: add elm_entry_input_panel_return_key_autoenable_set API.
authorjihoon <jihoon@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 28 Feb 2012 01:50:19 +0000 (01:50 +0000)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 28 Feb 2012 23:29:51 +0000 (08:29 +0900)
Set whether the return key on the input panel is disabled automatically when entry has no text.

Change-Id: I59123f6f2b3e45f4d7100fa707f3e08ad33ff168
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68484 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_entry.c
src/lib/elm_entry.h

index bcf45c5..864166e 100644 (file)
@@ -74,6 +74,7 @@ struct _Widget_Data
    Eina_Bool input_panel_enable : 1;
    Eina_Bool prediction_allow : 1;
    Eina_Bool input_panel_return_key_disabled : 1;
+   Eina_Bool autoreturnkey : 1;
 //// TIZEN ONLY
    Evas_Object *hoversel;
    Evas_Object *mgf_proxy;
@@ -838,6 +839,21 @@ _sizing_eval(Evas_Object *obj)
 }
 
 static void
+_check_enable_return_key(Evas_Object *obj)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   Eina_Bool return_key_disabled = EINA_FALSE;
+   if (!wd) return;
+
+   if (!wd->autoreturnkey) return;
+
+   if (elm_entry_is_empty(obj) == EINA_TRUE)
+     return_key_disabled = EINA_TRUE;
+
+   elm_entry_input_panel_return_key_disabled_set(obj, return_key_disabled);
+}
+
+static void
 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
@@ -852,6 +868,7 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
         if (top && wd->input_panel_enable)
           elm_win_keyboard_mode_set(top, ELM_WIN_KEYBOARD_ON);
         evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
+        _check_enable_return_key(obj);
         wd->mgf_type = _ENTRY_MAGNIFIER_FIXEDSIZE;
      }
    else
@@ -1850,6 +1867,7 @@ _entry_changed_common_handling(void *data, const char *event)
    /* callback - this could call callbacks that delete the entry... thus...
     * any access to wd after this could be invalid */
    evas_object_smart_callback_call(data, event, NULL);
+   _check_enable_return_key(data);
 }
 
 static void
@@ -4419,6 +4437,17 @@ elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj)
    return wd->input_panel_return_key_disabled;
 }
 
+EAPI void
+elm_entry_input_panel_return_key_autoenable_set(Evas_Object *obj, Eina_Bool on)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   wd->autoreturnkey = on;
+   _check_enable_return_key(obj);
+}
+
 EINA_DEPRECATED EAPI void
 elm_entry_autoperiod_set(Evas_Object *obj __UNUSED__, Eina_Bool autoperiod __UNUSED__)
 {
index 366ef06..71f56fa 100644 (file)
@@ -1301,6 +1301,18 @@ EAPI void                   elm_entry_input_panel_return_key_disabled_set(Evas_O
 EAPI Eina_Bool              elm_entry_input_panel_return_key_disabled_get(const Evas_Object *obj);
 
 /**
+ * Set whether the return key on the input panel is disabled automatically when entry has no text.
+ *
+ * If @p on is EINA_TRUE, The return key on input panel is disabled when the entry has no text.
+ * The return Key on the input panel is automatically enabled when the entry has text.
+ * The default value is EINA_FALSE.
+ *
+ * @param obj The entry object
+ * @param on If @p on is EINA_TRUE, the return key is automatically disabled when the entry has no text.
+ */
+EAPI void                   elm_entry_input_panel_return_key_autoenable_set(Evas_Object *obj, Eina_Bool on);
+
+/**
  * Reset the input method context of the entry if needed. 
  *
  * This can be necessary in the case where modifying the buffer would confuse on-going input method behavior