Re: Keyevent
- From: Paolo Costabel <paolo zebradevelopment com>
- To: José Maria Silveira Neto <silveiraneto gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Keyevent
- Date: Wed, 29 Dec 2004 09:37:42 -0800
You need to add
gtk_widget_set_events(janela, GDK_BUTTON_RELEASE_MASK);
Also, button release refers to the mouse. You cannot use a key handler
for it.
Try this:
gint e_button_up (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
printf("button %d UP \n", event->button);
return TRUE;
}
Cheers,
José Maria Silveira Neto wrote:
Hi, I'm developing a game with SDL and GTK.
I having a problem because I only can use key_press_event but not
button_release_event.
I wrote a small code to show my problem:
---------------------------------------------------------------------------------------------------------------
#include<gtk/gtk.h>
gint e_keyup (GtkWidget *widget, GdkEventKey *event){
printf("%d UP \n", event->keyval);
return TRUE;
}
gint e_keydown (GtkWidget *widget, GdkEventKey *event){
printf("%d DOWN \n", event->keyval);
return TRUE;
}
int main(gint arc, gchar **argv){
GtkWidget *janela;
gtk_init(&arc, &argv);
janela = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(janela),"Key Event");
gtk_signal_connect(GTK_OBJECT(janela), "delete_event",
GTK_SIGNAL_FUNC(gtk_main_quit), 0);
g_signal_connect (G_OBJECT (janela), "destroy", G_CALLBACK
(gtk_main_quit), NULL);
gtk_signal_connect(GTK_OBJECT(janela),
"key_press_event",GTK_SIGNAL_FUNC(e_keydown), 0);
gtk_signal_connect(GTK_OBJECT(janela),
"button_release_event",GTK_SIGNAL_FUNC(e_keyup), 0);
gtk_widget_show(janela);
gtk_main();
}
---------------------------------------------------------------------------------------------------------------
Salve it as key.c and compile it:
$gcc key.c -o key `pkg-config --libs --cflags gtk+-2.0`
You'll see that only key down event are occurring.
Does anybody know how to make button_release_event works?
Thanks a lot.
Fortaleza-CE, Brazil.
Silveira Neto
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
- References:
- Keyevent
- From: =?ISO-8859-1?Q?Jos=E9_Maria_Silveira_Neto?=
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]