[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GTK drawing area cannot get keyboard events
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: gtk-app-devel-list gnome org
- Subject: Re: GTK drawing area cannot get keyboard events
- Date: Sat, 8 Sep 2007 23:51:38 +0200
On Sat, Sep 08, 2007 at 02:21:11PM -0700, Tom Trebisky wrote:
> I have spent a couple of half-days trying to get keyboard events from a
> GTK drawing area with no luck,
I suppose you have read thread
http://mail.gnome.org/archives/gtk-list/2007-September/msg00015.html
> I am getting mouse events nicely from the drawing area, but have been
> entirely stumped in getting keyboard events. I have done google searches
> on the topic and taken the advice given, the code that I think is
> relevant is:
>
> GTK_WIDGET_SET_FLAGS ( da, GTK_CAN_FOCUS );
This is OK.
> g_signal_connect ( GTK_OBJECT(da), "focus_event",
> GTK_SIGNAL_FUNC(focus_handler), NULL );
This is written in some archaic dialect (although not
entirely, the corresponding archaic counterpart of
g_signal_connect() is gtk_signal_connect()). Code written
in the last 5 years should read
g_signal_connect(da, "focus-event",
G_CALLBACK(focus_handler), NULL);
Nevertheless, the functionality is the same.
> gtk_widget_add_events ( GTK_WIDGET(da), GDK_FOCUS_CHANGE );
And this is the bug. GDK_FOCUS_CHANGE is not an event mask
(i.e. GdkEventMask value), it's an event type (i.e.
GdkEventType valye). It should be GDK_FOCUS_CHANGE_MASK.
Ditto in the key press case.
Also ensure you add events before the widget is realized.
Yeti
--
http://gwyddion.net/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]