This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 7a1b15656fc557d5c5abd9ef7ce067ff21eb196e
Author: Carsten Haitzler <[email protected]>
AuthorDate: Sat Jan 17 16:17:54 2026 +0000

    elm - entry - add intercept func to allow global input filtering
    
    this allows you to intercept arrow keys, tab etc. and not pass them on
    so you can do things yourself with them. you cvan also intercept nay
    input so the entry can't process it too.
    
    @feat
---
 src/lib/edje/edje_entry.c             |  1 +
 src/lib/elementary/elm_entry.c        | 19 +++++++++++++++++--
 src/lib/elementary/elm_entry_legacy.h | 19 +++++++++++++++++++
 src/lib/elementary/elm_widget_entry.h |  5 +++++
 4 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index ca3aace784..6dcc5cab4b 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -1771,6 +1771,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
      return;
    if (!ev->key) return;
 
+   if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
    _edje_emit(ed, "entry,keydown", rp->part->name);
 #ifdef HAVE_ECORE_IMF
    if (en->imf_context)
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index 24f1af05b7..c2816efd1b 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -2020,13 +2020,28 @@ _key_down_cb(void *data,
                Evas_Object *obj EINA_UNUSED,
                void *event_info)
 {
+   ELM_ENTRY_DATA_GET(data, sd);
    Evas_Event_Key_Down *ev = event_info;
    /* First check if context menu disabled is false or not, and
     * then check for key id */
    if ((!_elm_config->context_menu_disabled) && !strcmp(ev->key, "Menu"))
      _menu_call(data);
+   if (sd->intercept.func)
+     {
+        if (sd->intercept.func(sd->intercept.data, data, ev))
+           ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+     }
 }
 
+EAPI void
+elm_entry_key_down_intercept_set(Evas_Object *obj, Eina_Bool (*func) (void *data, Evas_Object *obj, Evas_Event_Key_Down *ev), void *data)
+{
+  ELM_ENTRY_DATA_GET_OR_RETURN(obj, sd);
+  sd->intercept.data = ""
+  sd->intercept.func = func;
+}
+
+
 static void
 _mouse_down_cb(void *data,
                Evas *evas EINA_UNUSED,
@@ -3893,8 +3908,8 @@ _elm_entry_efl_canvas_group_group_add(Eo *obj, Elm_Entry_Data *priv)
    edje_object_text_markup_filter_callback_add
      (priv->entry_edje, "elm.text", _markup_filter_cb, obj);
 
-   evas_object_event_callback_add
-     (priv->entry_edje, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, obj);
+   evas_object_event_callback_priority_add
+     (priv->entry_edje, EVAS_CALLBACK_KEY_DOWN, -1000, _key_down_cb, obj);
    evas_object_event_callback_add
      (priv->entry_edje, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, obj);
    evas_object_event_callback_add
diff --git a/src/lib/elementary/elm_entry_legacy.h b/src/lib/elementary/elm_entry_legacy.h
index 9d87e54e54..4b20e49cbc 100644
--- a/src/lib/elementary/elm_entry_legacy.h
+++ b/src/lib/elementary/elm_entry_legacy.h
@@ -85,3 +85,22 @@ EAPI void               elm_entry_file_get(const Evas_Object *obj, const char **
  * @ingroup Elm_Entry_Group
  */
 EAPI void elm_entry_calc_force(Evas_Object *obj);
+
+/**
+ * Set an intercept function for key down events
+ *
+ * This setsd a function that is called on key down events that returns
+ * EINA_FALSE if the key pressed is uninteresting and should be passed on for
+ * normal processing. If the function thinks the key needs special
+ * handling and it should not be passed onto other handling, then return
+ * EINA_TRUE.
+ *
+ * @ingroup Elm_Entry_Group
+ *
+ * @param[in] obj The entry object
+ * @param[in] func The function to call on each key down event to do the intercepting
+ * @param[in] data Data pointer to pass to the intercept function
+ *
+ * @since 1.30
+ */
+EAPI void               elm_entry_key_down_intercept_set(Evas_Object *obj, Eina_Bool (*func) (void *data, Evas_Object *obj, Evas_Event_Key_Down *ev), void *data);
diff --git a/src/lib/elementary/elm_widget_entry.h b/src/lib/elementary/elm_widget_entry.h
index 8844e970d5..83bedd7930 100644
--- a/src/lib/elementary/elm_widget_entry.h
+++ b/src/lib/elementary/elm_widget_entry.h
@@ -83,6 +83,11 @@ struct _Elm_Entry_Data
         Evas_Object *hover; /**< hover object */
         const char  *hover_style; /**< style of a hover object */
      } anchor_hover;
+  struct
+    {
+      Eina_Bool (*func) (void *data, Evas_Object *obj, Evas_Event_Key_Down *ev);
+      void       *data;
+    } intercept;
 
    Elm_Cnp_Mode                          cnp_mode;
    Elm_Sel_Format                        drop_format;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to