On Thu, 26 Feb 2009 16:33:10 +0530
varun shrivastava <[email protected]> wrote:
>its not button-press its key-press-event
>> can anybody tell me how i can pass the button-press-event on a particular
>> widget. Means when i press A button then A should go on that widget.
>>
>> I am unable to work out on this.
>>
>> Can anybody help me
/* cc -g `pkg-config --cflags --libs gtk+-2.0` -o keywatch keywatch.c */
#include <gtk/gtk.h>
#include <stdlib.h>
#include <gdk/gdkkeysyms.h>
gboolean on_key_press (GtkWidget * window,
GdkEventKey* pKey,
gpointer userdata){
if (pKey->type == GDK_KEY_PRESS){
g_print("%i\n", pKey->keyval);
switch (pKey->keyval)
{
case GDK_Escape :
gtk_main_quit ();
break;
}
}
return FALSE;
}
int
main (int argc,
char *argv[])
{
GtkWidget * window;
/* Gtk2->init; */
gtk_init (&argc, &argv);
/* my $window = new Gtk2::Window; */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window,
"key-press-event",
G_CALLBACK (on_key_press),
NULL);
/* $window->show_all(); */
gtk_widget_show_all (window);
/* Gtk2->main; */
gtk_main ();
return 0;
}
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://www.zentara.net/~zentaran/My_Petition_to_the_Great_Cosmic_Conciousness.html
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list