Re: How to control both mouse and keyboard events in application



Am Freitag, den 09.09.2005, 16:40 +0900 schrieb Diana Joseph:
Dear All
 I am modifying GPE application to handle keyboard events. Especially the 
Tree. 

For eg. in gpe-gallery..

my main window listens to keyboard-event and connects to this callback...The 
GDK_Left, GDK_Right and other keys with integer argument or without any 
argument work but GDK_F1/F2/F3/F4 that has to pass the widget and data does 
not have any effect.

[...]

case GDK_F1:

gtk_signal_connect (GTK_OBJECT (image_event_box), "button-press-event", 
GTK_SIGNAL_FUNC (button_down), scrolled_window);

break;

case GDK_F2:

gtk_signal_connect (GTK_OBJECT (image_event_box), "button-release-event", 
GTK_SIGNAL_FUNC (button_up), NULL);

break;

case GDK_F3:

gtk_signal_connect (GTK_OBJECT (image_event_box), "motion-notify-event", 
GTK_SIGNAL_FUNC (motion_notify), scrolled_window);

break;

}

Any time your handler sees one of theses key events you're connecting
again to the image event box. If at all this should be done one time at
startup.

What do you want to achieve when GDK_Fx is sent? Looks as if you want to
scroll the named windows or move the caret in it?

If so, I see two options of implementing:

You could create a synthetic event and send it to the target widget
(I've never gotten that working)

or

you can change the received key event to something else and set the
result of your handler to the value that says "the event is not handled,
put it in the event handler chain again". This would be something like:

case GDK_F1
event->.keyval := GDK_PAGE_UP;
return xxx; // dunno what value is right, look in the docs


HTH,
Marc





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