From 720e5ba490609daadbe99c86c16606ccbe1acd4d Mon Sep 17 00:00:00 2001 From: jihoon Date: Tue, 28 Feb 2012 01:50:19 +0000 Subject: [PATCH] elm/entry: add elm_entry_input_panel_return_key_autoenable_set API. Set whether the return key on the input panel is disabled automatically when entry has no text. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68484 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_entry.c | 29 +++++++++++++++++++++++++++++ src/lib/elm_entry.h | 12 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index ab8442d..252327d 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -75,6 +75,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; }; struct _Elm_Entry_Context_Menu_Item @@ -791,6 +792,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); @@ -804,6 +820,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); } else { @@ -1506,6 +1523,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 @@ -3732,3 +3750,14 @@ 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); +} + diff --git a/src/lib/elm_entry.h b/src/lib/elm_entry.h index 3a0dbac..7df3e74 100644 --- a/src/lib/elm_entry.h +++ b/src/lib/elm_entry.h @@ -1277,6 +1277,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 -- 2.7.4