elm focus: Added elm_object_focus_set() API. Use this instead elm_object_focus/unfocus().
authorseoz <seoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 3 Aug 2011 11:46:23 +0000 (11:46 +0000)
committerMike McCormack <mj.mccormack@samsung.com>
Thu, 10 Nov 2011 00:08:21 +0000 (09:08 +0900)
git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@62049 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Elementary.h.in
src/lib/elm_main.c
src/lib/elm_notify.c
src/lib/elm_pager.c
src/lib/elm_widget.c
src/lib/elm_win.c

index 67c7e48..d55bc1b 100644 (file)
@@ -2316,6 +2316,24 @@ extern "C" {
     * @ingroup Focus
     */
    EAPI Eina_Bool        elm_object_focus_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
+   /**
+    * Set/unset focus to a given Elementary object.
+    *
+    * @param obj The Elementary object to operate on.
+    * @param enable @c EINA_TRUE Set focus to a given object,
+    *               @c EINA_FALSE Unset focus to a given object.
+    *
+    * @note When you set focus to this object, if it can handle focus, will
+    * take the focus away from the one who had it previously and will, for
+    * now on, be the one receiving input events. Unsetting focus will remove
+    * the focus from @p obj, passing it back to the previous element in the
+    * focus chain list.
+    *
+    * @see elm_object_focus_get(), elm_object_focus_custom_chain_get()
+    *
+    * @ingroup Focus
+    */
+   EAPI void             elm_object_focus_set(Evas_Object *obj, Eina_Bool focus) EINA_ARG_NONNULL(1);
 
    /**
     * Make a given Elementary object the focused one.
index 85a9a2c..0c825ca 100644 (file)
@@ -1529,21 +1529,34 @@ elm_object_focus_get(const Evas_Object *obj)
 }
 
 EAPI void
-elm_object_focus(Evas_Object *obj)
+elm_object_focus_set(Evas_Object *obj,
+                     Eina_Bool    focus)
 {
    EINA_SAFETY_ON_NULL_RETURN(obj);
-   if (elm_widget_focus_get(obj))
-     return;
+   if (focus)
+     {
+        if (elm_widget_focus_get(obj)) return;
+        elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
+     }
+   else
+     {
+        if (!elm_widget_can_focus_get(obj)) return;
+        elm_widget_focused_object_clear(obj);
+     }
+}
 
-   elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
+EAPI void
+elm_object_focus(Evas_Object *obj)
+{
+   EINA_SAFETY_ON_NULL_RETURN(obj);
+   elm_object_focus_set(obj, EINA_TRUE);
 }
 
 EAPI void
 elm_object_unfocus(Evas_Object *obj)
 {
    EINA_SAFETY_ON_NULL_RETURN(obj);
-   if (!elm_widget_can_focus_get(obj)) return;
-   elm_widget_focused_object_clear(obj);
+   elm_object_focus_set(obj, EINA_FALSE);
 }
 
 EAPI void
index e63245b..85acf1e 100644 (file)
@@ -363,7 +363,7 @@ _show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_i
    if (!wd->repeat_events)
      evas_object_show(wd->block_events);
    _timer_init(obj, wd);
-   elm_object_focus(obj);
+   elm_object_focus_set(obj, EINA_TRUE);
 }
 
 static void
index 1bf242d..e721a3c 100644 (file)
@@ -193,7 +193,7 @@ _eval_top(Evas_Object *obj)
         else if (wd->oldtop)
           {
              if (elm_object_focus_get(wd->oldtop->content))
-               elm_widget_focused_object_clear(wd->oldtop->content);
+               elm_object_focus_set(wd->top->content, EINA_TRUE);
              if (wd->oldtop->popme)
                edje_object_signal_emit(o, "elm,action,show", "elm");
              else
index 9079027..0e89c2a 100644 (file)
@@ -3293,8 +3293,8 @@ _if_focused_revert(Evas_Object *obj,
         newest = _newest_focus_order_get(top, &newest_focus_order, can_focus_only);
         if (newest)
           {
-             elm_object_unfocus(newest);
-             elm_object_focus(newest);
+             elm_object_focus_set(newest, EINA_FALSE);
+             elm_object_focus_set(newest, EINA_TRUE);
           }
      }
 }
index 7e6f957..837b2f3 100644 (file)
@@ -2582,7 +2582,7 @@ elm_win_inwin_activate(Evas_Object *obj)
    evas_object_raise(obj);
    evas_object_show(obj);
    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
-   elm_object_focus(obj);
+   elm_object_focus_set(obj, EINA_TRUE);
 }
 
 EAPI void