kyanh@xxxxx ha scritto lo scorso 19/03/2005 16:03:
Hi,
please help me: for a special purpose, i want to ignore some events. For example, in my multiline text editor, the keys Key Up and Key Down must be ignored in some cases.
I tried but failed. Thank you very much for replying.
You have to write your key_press_event callback, catch the event->keyval
you wish to treat and stop the signal propagation; something like this:
gboolean on_tvShell_key_press_event (GtkWidget * widget,
GdkEventKey * event,
gpointer user_data)
{
GtkTextBuffer * buffer;
GtkWidget * tvShell;
gboolean ret = FALSE;
tvShell = lookup_widget (widget, "tvShell");
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tvShell));
switch (event->keyval) {
case (GDK_Return):
/* the return key has been hit - are you interested in it?
*/
ret = FALSE;
break;
case (GDK_Up):
/* the arrow-up key has been hit - let's drop this
*/
g_signal_stop_emission_by_name (widget, "key-press");
ret = TRUE;
break;
case (GDK_Down):
ret = FALSE;
break;
case (GDK_Escape):
.
.
.
default:
ret = FALSE;
break;
}
return (ret);
}
_______________________________________________
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list