Re: GTK app with no keyboard/mouse
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: GTK app with no keyboard/mouse
- Date: Wed, 23 Feb 2005 14:18:19 -0800
Mike Rosenlof wrote:
This system will have a display, and a remote control device. I'm
planning on a separate thread from the GUI which receives the remote
codes, interprets them, and injects appropriate events into the GUI.
Let's assume for the moment that the remote has just six buttons. Menu,
up, down, left, right, select. Any thoughts on the best way to inject
events? So far I have found that a "move-focus" signal on the window
containing a bunch of button and slider widgets is not the answer (for
direction navigation). Neither does gtk_window_propagate_key_event()
seem to be what I want. I, of course, want to use the GTK
infrastructure instead of rolling my own. Any suggestions?
As another poster mentioned, I too have had problems using
gdk_event_put() to synthesize events. What has worked for me is using
XSendEvent(), passing it the window of the target widget. You need to
call it twice, for ButtonPress and ButtonRelease. If you're just doing
button presses, I believe you can use gtk_button_clicked()[1] instead.
There are probably other similar functions you can call for other
widgets that are "clickable" in the sense of activating them; the API
docs will help here. Note that GtkButton is a subclass for a bunch of
different button types (like GtkCheckButton), so gtk_button_click() will
work for all of them.
For widget navigation, I'd suggest using a state machine. So you keep
track of which widget has focus, and create a state table for the
transitions, so you basically have a list of starting widgets, and for
each of the four arrow directions, you have a widget to move to. Then
just use gdk_widget_grab_focus() to make the change.
-brian
[1]
http://developer.gnome.org/doc/API/2.0/gtk/GtkButton.html#gtk-button-clicked
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]