Re: Keypress and gtk_drawing_area
- From: Olexiy Avramchenko <olexiy irtech cn ua>
- To: Russell Shaw <rjshaw iprimus com au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Keypress and gtk_drawing_area
- Date: Fri, 17 Oct 2003 10:14:20 +0300
Russell Shaw wrote:
Hi,
When i press a key, the callback is invoked ok with:
g_signal_connect(G_OBJECT(window),"key_press_event",G_CALLBACK(key_press_cb),NULL);
Now i put a gtk_drawing_area in window and did:
gtk_widget_set_events(drawing_area,GDK_KEY_PRESS_MASK);
g_signal_connect(G_OBJECT(draw_area),"key_press_event",G_CALLBACK(key_press_cb),NULL);
but the callback no longer works.
You should:
1. Set GTK_CAN_FOCUS flag on area.
2. Use gtk_widget_grab_focus() function to grab keyboard focus.
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-grab-focus
You can check whether your widget already has a focus with
GTK_WIDGET_HAS_FOCUS macro.
In my app I grab the focus when user press the mouse button on drawing area.
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]