Re: Key press
- From: Havoc Pennington <hp redhat com>
- To: jylam lnxscene org
- Cc: gtk-list gnome org
- Subject: Re: Key press
- Date: 22 Apr 2002 11:33:00 -0400
Jean-Yves Lamoureux <jylam lnxscene org> writes:
> I've a problem to get current keyboard status.
> (MyWindow->image is a DrawingArea)
> I wonder where is the problem. I tell gtk to grab KEY_PRESS, with the right
> mask. Then I link a function to the press and release events, but nothing
> happens, function's not called. If someone can help me ...
> Thanks a lot
> gtk_widget_add_events (GTK_WIDGET (MyWindow->image), GDK_KEY_PRESS_MASK);
> gtk_signal_connect (GTK_OBJECT (MyWindow->image), "key_press_event",
> GTK_SIGNAL_FUNC (LastKeyPressed), NULL);
> gtk_signal_connect( GTK_OBJECT (MyWindow->image),
See the sentence about "to receive keyboard events" at the end of the
Description section for 2.0 drawing area docs:
In 1.2 it's somewhat more complicated, in addition to setting
GTK_CAN_FOCUS you need to handle focus in/out events by
setting/unsetting the GTK_HAS_FOCUS flag.
You also need the area to have focus, obviously, usually the user
would tab to it to focus it.
If you don't want to worry about where the focus is, maybe you want to
get key events on the toplevel window instead of a particular widget.
] [Thread Prev