1 #include "evas_common.h"
2 #include "evas_private.h"
11 * Sets focus to the given object.
13 * @param obj The object to be focused or unfocused.
14 * @param focus set or remove focus to the object.
16 * Changing focus only affects where key events go.
17 * There can be only one object focused at any time.
19 * If the parameter (@p focus) is set, the passed object will be set as the
20 * currently focused object. It will receive all keyboard events that are not
21 * exclusive key grabs on other objects.
23 * @see evas_object_focus_get
25 * @see evas_object_key_grab
26 * @see evas_object_key_ungrab
29 evas_object_focus_set(Evas_Object *obj, Evas_Bool focus)
31 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
37 if (obj->focused) return;
38 if (obj->layer->evas->focused)
39 evas_object_focus_set(obj->layer->evas->focused, 0);
41 obj->layer->evas->focused = obj;
42 evas_object_event_callback_call(obj, EVAS_CALLBACK_FOCUS_IN, NULL);
46 if (!obj->focused) return;
48 obj->layer->evas->focused = NULL;
49 evas_object_event_callback_call(obj, EVAS_CALLBACK_FOCUS_OUT, NULL);
54 * Test if the object has focus.
56 * @param obj The object to be tested.
58 * If the passed object is the currently focused object 1 is returned,
61 * @see evas_object_focus_set
63 * @see evas_object_key_grab
64 * @see evas_object_key_ungrab
66 * @return 1 if the object has the focus, 0 otherwise.
69 evas_object_focus_get(const Evas_Object *obj)
71 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
78 * Retrieve the object that currently has focus.
80 * @param e The @c Evas canvas to query focus on.
82 * Returns the object that currently has focus, NULL otherwise.
84 * @see evas_object_focus_set
85 * @see evas_object_focus_get
86 * @see evas_object_key_grab
87 * @see evas_object_key_ungrab
89 * @return The object that has focus or NULL is there is not one.
92 evas_focus_get(const Evas *e)
94 MAGIC_CHECK(e, Evas, MAGIC_EVAS);