Search code examples
cgtkgnomeglibclutter

How to shift the key focus from the clutter_stage to clutter_actor?


I have some clutter_actors placed over the clutter_stage. Whenever i want to shift the focus from the clutter_stage to clutter_actor i use clutter_stage_set_key_focus(clutter_stage,clutter_actor) .

But when i press any key related to clutter_actor it goes to the callback function of clutter_stage. Do i need to use any other function to change the key focus from clutter_stage to clutter_actor.


Solution

  • the actor needs to be reactive, and you need to use the key-press-event and/or the key-release-event signals on the actor itself.

    Clutter event-related signals follow a capture/bubble phase:

    http://developer.gnome.org/clutter/stable/ClutterActor.html#ClutterActor-event-handling

    if you leave the key press/release signal handlers registered on the stage you'll see an emission from them during capture, and an eventual emission on them during bubble unless the actor returned TRUE from the signal handler, to stop the signal propagation.