From d2c3856d078586e9915ef550af9d5087d6092e3a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Aug 2012 07:00:26 +0000 Subject: [PATCH] elementary: add smart callback "focus-in" and "focus-out". NOTE: Glima could you review this, I am really not sure I should have implemented it this way. SVN revision: 74818 --- ChangeLog | 4 ++++ NEWS | 1 + src/lib/elm_widget.c | 31 ++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ccfc4a..1a9e2f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -366,3 +366,7 @@ 2012-08-02 Cedric Bail * Fix elm_image_orient_set/get. + +2012-08-03 Cedric Bail + + * Add smart callback "focus-in" and "focus-out". diff --git a/NEWS b/NEWS index 13f8019..854dd81 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,7 @@ Additions: * Initialize Emotion when necessary. * Elm_Win_Trap and elm_win_trap_set() to allow e17 integration. * elm_flip_go_to() + * Add smart callback "focus-in" and "focus-out" when an Elementary object gain or loose focus. Fixes: diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index f4e13f0..f6e0d3d 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -368,6 +368,25 @@ _elm_widget_focus_direction_func_unimplemented(const Evas_Object *obj __UNUSED__ } static Eina_Bool +_elm_widget_focus_call(Elm_Widget_Smart_Data *sd, Evas_Object *obj) +{ + Eina_Bool r = EINA_FALSE; + + sd->api->on_focus(obj); + if (_elm_legacy_is(obj) && COMPAT_SMART_DATA(sd)->focus) + { + COMPAT_SMART_DATA(sd)->focus(obj); + r = EINA_TRUE; + } + if (sd->focused) + evas_object_smart_callback_call(obj, "focus-in", NULL); + else + evas_object_smart_callback_call(obj, "focus-out", NULL); + + return r; +} + +static Eina_Bool _elm_widget_sub_object_add_func(Evas_Object *obj, Evas_Object *sobj) { @@ -831,9 +850,7 @@ _parent_focus(Evas_Object *obj) if (sd->top_win_focused) { sd->focused = EINA_TRUE; - sd->api->on_focus(obj); - if (_elm_legacy_is(obj) && COMPAT_SMART_DATA(sd)->focus) - COMPAT_SMART_DATA(sd)->focus(obj); + _elm_widget_focus_call(sd, obj); _elm_widget_focus_region_show(obj); } sd->focus_order_on_calc = EINA_FALSE; @@ -2726,12 +2743,10 @@ elm_widget_focus_set(Evas_Object *obj, focus_order++; sd->focus_order = focus_order; sd->focused = EINA_TRUE; - sd->api->on_focus(obj); } - if (_elm_legacy_is(obj) && COMPAT_SMART_DATA(sd)->focus) + if (_elm_widget_focus_call(sd, obj)) { - COMPAT_SMART_DATA(sd)->focus(obj); return; } else @@ -2814,9 +2829,7 @@ elm_widget_focused_object_clear(Evas_Object *obj) } } sd->focused = EINA_FALSE; - sd->api->on_focus(obj); - if (_elm_legacy_is(obj) && COMPAT_SMART_DATA(sd)->focus) - COMPAT_SMART_DATA(sd)->focus(obj); + _elm_widget_focus_call(sd, obj); } EAPI void -- 2.7.4