Frage

I have to create a vertical menu using clutter in C. Can anyone help me how to implement focus shift using the navigation keys for the menu where i want to highlight the focused menu option.

War es hilfreich?

Lösung

the easiest way is to mark the actor that contains all the menu items as reactive, assign to it the key focus using clutter_actor_grab_key_focus() and connect to the key-press-event signal. then you can use clutter_event_get_key_symbol() on the ClutterEvent passed to the signal and match it agains key symbols like CLUTTER_KEY_Down or CLUTTER_KEY_Up.

then there's even the possibility to use ClutterBindingPool to handle tuples of (key symbol, modifier) and assign them to a specific callback function.

for more information, see the API reference:

http://developer.gnome.org/clutter/stable/ClutterActor.html#clutter-actor-grab-key-focus http://developer.gnome.org/clutter/stable/ClutterActor.html#ClutterActor-key-press-event http://developer.gnome.org/clutter/stable/clutter-Events.html#clutter-event-get-key-symbol http://developer.gnome.org/clutter/stable/clutter-Key-Bindings.html

the list of key symbols in in the clutter-keysyms.h header:

http://git.gnome.org/browse/clutter/tree/clutter/clutter-keysyms.h

there are various recipes in the Cookbook as well:

https://developer.gnome.org/clutter-cookbook/stable/events-handling-key-events.html

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top