GTK drawing area cannot get keyboard events



Hello,

I have spent a couple of half-days trying to get keyboard events from a
GTK drawing area with no luck, so I figure it is time to ask the experts
here.  My application has a very simple widget hierarchy, a main window
holds a vbox which holds a drawing area.  The vbox is there because someday
soon I expect to put a control panel above the drawing area.  And I am
using gtk-2.0 under Fedora Core 7, gtk 2.10.14 as of today.

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 );

         g_signal_connect ( GTK_OBJECT(da), "focus_event",
                 GTK_SIGNAL_FUNC(focus_handler), NULL );
         gtk_widget_add_events ( GTK_WIDGET(da), GDK_FOCUS_CHANGE );

         g_signal_connect ( GTK_OBJECT(da), "key_press_event",
                 GTK_SIGNAL_FUNC(keyboard_handler), NULL );
         gtk_widget_add_events ( GTK_WIDGET(da), GDK_KEY_PRESS );

The keyboard and focus handlers just contain printf statements at
this stage, if I ever trigger them, I'll be on to other things.

If you are willing to look deeper, all the code for this project is
under SVN and you can easily look at gtopo.c using a browser via the
link:

        http://cholla.mmto.org/svn/gtopo/trunk/

The project website is:

        http://cholla.mmto.org/gtopo

Thanks greatly for your help and advice!

        Tom
-- 
Tom Trebisky
MMT Observatory
University of Arizona -- Tucson
tom mmto org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]