Re: [gtk-list] Can DrawingArea produce key press event?




Yeah, this is easy enough. You need to create a GTK event box and then add
your drawing area to it, something like:

   GtkWidget *evtbox;
   GtkWidget *drawing_area;

   /* Setup your drawing area here.. */

   evtbox = gtk_event_box_new();
   gtk_signal_connect(GTK_OBJECT(evtbox),
                      "key_press_event",
                      GTK_SIGNAL_FUNC(key_press_cb),
                      NULL);
   gtk_widget_set_events(evtbox, GDK_KEY_PRESS_MASK);
   gtk_container_add(GTK_CONTAINER(evtbox), drawing_area);
   gtk_widget_show(evtbox);

I hope this helps..

Regards,
   Cody

On Tue, 10 Aug 1999, hj wrote:

> I want to catch key press event and draw string in DrawingArea.
> 
>         gtk_signal_connect(GTK_OBJECT(drawingArea),"key_press_event",GTK_SIGNAL_FUNC(keyPressEvent),NULL);
>         gtk_signal_connect(GTK_OBJECT(drawingArea),"expose_event",GTK_SIGNAL_FUNC(mainExposeEvent),NULL);
>         gnome_app_set_contents(GNOME_APP(app),drawingArea);
> 
> DrawingArea don't call function keyReleaseEvent when I press any key. How can I do?
> 
> ÿôèº{.nÇ+‰·ÿ™¨¥þ˧²æìr¸›zdþX¬·úު笷úÞv­ýÊ&ÿ÷^¿ùî
> 



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