Add Actor::grab_key_focus() method

Bug 1003 - Add clutter_actor_take_key_focus()

The grab_key_focus() method is just a simple wrapper around
clutter_stage_take_key_focus() that removes the need to get
the ClutterStage of an actor in order to set the key focus.

Based on a patch by Xan López.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Signed-off-by: Øyvind Kolås <pippin@linux.intel.com>
This commit is contained in:
Emmanuele Bassi 2008-12-11 11:22:46 +00:00 committed by Emmanuele Bassi
parent 40fb75052b
commit 430d1cf347
2 changed files with 27 additions and 0 deletions

View File

@ -7564,3 +7564,28 @@ clutter_actor_allocate_preferred_size (ClutterActor *self,
clutter_actor_allocate (self, &actor_box, absolute_origin_changed);
}
/**
* clutter_actor_grab_key_focus:
* @self: a #ClutterActor
*
* Sets the key focus of the #ClutterStage including @self
* to this #ClutterActor.
*
* Since: 1.0
*/
void
clutter_actor_grab_key_focus (ClutterActor *self)
{
ClutterActor *parent;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
parent = clutter_actor_get_parent (self);
if (!parent)
return;
parent = clutter_actor_get_stage (self);
if (parent && CLUTTER_IS_STAGE (parent))
clutter_stage_set_key_focus (CLUTTER_STAGE (parent), self);
}

View File

@ -561,6 +561,8 @@ void clutter_actor_apply_relative_transform_to_point (ClutterActor *self,
gboolean clutter_actor_get_paint_visibility (ClutterActor *self);
void clutter_actor_grab_key_focus (ClutterActor *self);
G_END_DECLS
#endif /* _HAVE_CLUTTER_ACTOR_H */