Thanks for advice Richard Boaz But only I have a problem with your solution, the user must have the mouse all time inside of the drawing area if he want interact with the drawing area, and if he want interact with the menu he need to move the mouse or use the keyboard for interact with the menu. But I need that the user can interact with the drawing area only with selected the drawing area Without the mouse are inside of drawing area, Bucause at same time that he may interact with the window that contains the drawing area. And if I use the function for block the signal have the problem of that I can't select, copy, paste the text. --- Richard Boaz <riboaz@xxxxxxxxx> escribió: > you have gotten your panties into a serious twist. > > start over: > > when wanting to receive key press events in a > drawing area, you must do > all of the following: > > 1. set up the drawing area to receive key press > and/or release events. > 2. set up the drawing area to receive enter and > leave notify events. > 3. when receiving an enter notify event, you must > grab focus of the > drawing area and hold it until you receive the leave > notify event, and > then let it go! > > so, at creation of the drawing area: > > // connect the signals, at least: > g_signal_connect (da, "key_press_event", G_CALLBACK > (keyEvent), NULL); > g_signal_connect (da, "key_release_event", > G_CALLBACK (keyEvent), NULL); > g_signal_connect (da, "enter_notify_event", > G_CALLBACK (grabFocus), NULL); > g_signal_connect (da, "leave_notify_event", > G_CALLBACK (grabFocus), NULL); > > // set up the events to be received by the drawing > area, at least: > gtk_widget_set_events (da, gtk_widget_get_events > (da) > | GDK_LEAVE_NOTIFY_MASK > | GDK_ENTER_NOTIFY_MASK > | GDK_KEY_PRESS_MASK > | GDK_KEY_RELEASE_MASK); > > // define you grabFocus() callback > gboolean grabFocus(GtkWidget *widget, GdkEvent > *event, gpointer nil) > { // we must grab the focus when mouse enters to > receive key events > switch(event->type) > { > case GDK_ENTER_NOTIFY: > gtk_grab_add(GTK_WIDGET (widget)); > break; > case GDK_LEAVE_NOTIFY: > gtk_grab_remove(GTK_WIDGET (widget)); > break; > default: > break; > } > return TRUE; > } > > do it like this and when the mouse is inside the > drawing are, the drawing > are will receive all keyboard events. when the > mouse is outside the > drawing area, the entry area assigned the current > focus will receive the > keyboard events. clicking inside an entry area will > always assign focus > to that entry area. > > to answer your other question, g_signal_connect() > returns the signal > handler id you are looking for. save it when > creating the signal callback > and blocking and unblocking is easily done. > > richard > > ____________________________________________________________________________________ ¡Capacidad ilimitada de almacenamiento en tu correo! No te preocupes más por el espacio de tu cuenta con Correo Yahoo!: http://correo.yahoo.com.mx/ _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list