* @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.
}
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
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
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
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);
}
}
}
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