elm focus: Added elm_object_focus_set() API. Use this instead elm_object_focus/unfocus().
authorDaniel Juyung Seo <seojuyung2@gmail.com>
Wed, 3 Aug 2011 11:46:23 +0000 (11:46 +0000)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Wed, 3 Aug 2011 11:46:23 +0000 (11:46 +0000)
SVN revision: 62049

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 3a2f314..d15e928 100644 (file)
@@ -1144,6 +1144,25 @@ extern "C" {
    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.
     *
     * @param obj The Elementary object to make focused.
@@ -1153,10 +1172,11 @@ extern "C" {
     * the one receiving input events.
     *
     * @see elm_object_focus_get()
+    * @deprecated use elm_object_focus_set() instead.
     *
     * @ingroup Focus
     */
-   EAPI void             elm_object_focus(Evas_Object *obj) EINA_ARG_NONNULL(1);
+   EINA_DEPRECATED EAPI void             elm_object_focus(Evas_Object *obj) EINA_ARG_NONNULL(1);
 
    /**
     * Remove the focus from an Elementary object
@@ -1167,10 +1187,11 @@ extern "C" {
     * previous element in the focus chain list.
     *
     * @see elm_object_focus() and elm_object_focus_custom_chain_get()
+    * @deprecated use elm_object_focus_set() instead.
     *
     * @ingroup Focus
     */
-   EAPI void             elm_object_unfocus(Evas_Object *obj) EINA_ARG_NONNULL(1);
+   EINA_DEPRECATED EAPI void             elm_object_unfocus(Evas_Object *obj) EINA_ARG_NONNULL(1);
 
    /**
     * Set the ability for an Element object to be focused
index 712879e..0586b12 100644 (file)
@@ -2256,21 +2256,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 5ddf0a6..88d73b1 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 5d9a6f1..309af71 100644 (file)
@@ -177,7 +177,7 @@ _eval_top(Evas_Object *obj)
         if (wd->oldtop)
           {
              if (elm_object_focus_get(wd->oldtop->content))
-               elm_object_focus(wd->top->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 ab91968..f40fcb1 100644 (file)
@@ -3036,8 +3036,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 fc06829..fa8a83d 100644 (file)
@@ -414,7 +414,7 @@ _elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Objec
 {
    Elm_Win *win = data;
 
-   elm_object_focus(obj);
+   elm_object_focus_set(obj, EINA_TRUE);
    if (win->shot.info) _shot_handle(win);
 }
 
@@ -2489,7 +2489,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