Re: I need some help with key events
- From: JParker coinstar com
- To: Pablo Barbachano <lordnene yahoo es>
- Cc: gtk-app-devel-list gnome org, gtk-app-devel-list-admin gnome org
- Subject: Re: I need some help with key events
- Date: Fri, 3 Nov 2000 12:16:35 -0800
G'Day !
What is your error ?
On my laptop, g_print( ) tends to give me a SEGFAULT when I use it (if switched
to populating a label in my main window to avoid headaches ;-)
On my key presses, I specify particular keys I'm interested in via a switch (see
gdk header files). Might try capturing one known key and see if that works.
I can send you working gtk_gl_area code if you want.
cheers,
Jim Parker
Sailboat racing is not a matter of life and death .... It is far more important
than that !!!
Pablo Barbachano
<lordnene yahoo es> To: gtk-app-devel-list gnome org
Sent by: cc:
gtk-app-devel-list-admin Subject: I need some help with key events
@gnome.org
11/03/00 11:54 AM
look at the program attached.
Thanks.
_______________________________________________________________
Do You Yahoo!?
Consiga gratis su dirección @yahoo.es en http://correo.yahoo.es/*
* I want to catch keyboard events in a GtkGLArea widget, but I can't.
* The code is similar to this, but with a GtkGLArea widget, and
* not a GtkDrawingArea. Can't anyone help?
* Please, I'm very dissapointed, and I think that it isn't a bug
* of the GTK+ library, so, where is my error?
* Why does it catch mouse button events and no keyboard events??
* Thank you, and sorry for my english (is as bad as my code ;)
*/
#include <gtk/gtk.h>
GtkWidget *create_area (void);
gint key_press(GtkWidget *widget, GdkEventKey *event);
gint key_release(GtkWidget *widget, GdkEventKey *event);
gint button_press (GtkWidget *widget, GdkEventButton *event);
int main (int argc, char **argv)
{
GtkWidget *window, *area;
gtk_init (&argc, &argv);
area = create_area ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_events (window,
GDK_EXPOSURE_MASK|GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
gtk_window_set_title (GTK_WINDOW (window),"GTK+ bug?");
gtk_signal_connect (GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_container_add (GTK_CONTAINER (window),area);
gtk_widget_show (area);
gtk_widget_show (window);
gtk_main ();
return 0;
}
GtkWidget *create_area (void)
{
GtkWidget *widget;
widget = gtk_drawing_area_new ();
gtk_widget_set_events(widget,
GDK_EXPOSURE_MASK|
GDK_BUTTON_PRESS_MASK|
GDK_BUTTON_RELEASE_MASK|
GDK_KEY_PRESS_MASK|
GDK_KEY_RELEASE_MASK);
gtk_signal_connect (GTK_OBJECT(widget), "key_press_event",
GTK_SIGNAL_FUNC(key_press), NULL);
gtk_signal_connect (GTK_OBJECT(widget), "key_release_event",
GTK_SIGNAL_FUNC(key_release), NULL);
gtk_signal_connect (GTK_OBJECT(widget), "button_press_event",
GTK_SIGNAL_FUNC(button_press), NULL);
return widget;
}
gint key_press(GtkWidget *widget, GdkEventKey *event)
{
g_print ("\nkey press event");
return TRUE;
}
gint key_release(GtkWidget *widget, GdkEventKey *event)
{
g_print ("\nkey release event");
return TRUE;
}
gint button_press (GtkWidget *widget, GdkEventButton *event)
{
g_print ("\nbutton press event");
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]