Keyevent
- From: José Maria Silveira Neto <silveiraneto gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Keyevent
- Date: Wed, 29 Dec 2004 14:45:00 -0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]