Re: [gtk-list] plusocket



On Thu, 21 May 1998, George Zervas wrote:
> On a different note, how can I capture key press events over a drawing
> area. I tried using:
> gtk_signal_connect (GTK_OBJECT (drawing_area), "key_press_event",
> 			GTK_SIGNAL_FUCN(key_press), NULL);
> 
> and then I have (well before actually but anyway...)
> 
> static gint
> key_press (GtkWidget *widget, GdkEventKey *event)
> {
> ...
> }
> 
> but the events do not seem to happen when keys are pressed. Am I missing
> something? 
> TIA, Giorgos.

Are you sure the drawing area normally responds to key presses?  I know
for my latest little app, I needed a pixmap to respond to a mouse click so
I had to first add the GDK_BUTTON_PRESS_MASK to the widget's events using

gtk_widget_set_events(window, gtk_widget_get_events(window) | 
                      GDK_BUTTON_PRESS_MASK);

Then I could go ahead and connect the "button_press_event" signal to my
function.  Something to look in to, hope it helps.

---
"If the doors of perception were cleansed everything would appear
 to man as it is, infinite."  -- William Blake

Todd Pafford   galen@erols.com 



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