elm focus: Added elm_object_focus_set() API. Use this instead elm_object_focus/unfocus().

SVN revision: 62049
This commit is contained in:
Daniel Juyung Seo 2011-08-03 11:46:23 +00:00
parent 21d060dd09
commit 2f2ebe1835
6 changed files with 48 additions and 14 deletions

View File

@ -1143,6 +1143,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.
*
@ -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

View File

@ -2255,22 +2255,35 @@ elm_object_focus_get(const Evas_Object *obj)
return elm_widget_focus_get(obj);
}
EAPI void
elm_object_focus_set(Evas_Object *obj,
Eina_Bool focus)
{
EINA_SAFETY_ON_NULL_RETURN(obj);
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);
}
}
EAPI void
elm_object_focus(Evas_Object *obj)
{
EINA_SAFETY_ON_NULL_RETURN(obj);
if (elm_widget_focus_get(obj))
return;
elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
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

View 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

View 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

View 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);
}
}
}

View 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