Re: detect ctrl+c in key_press_event handler



Odd, you seem to be getting 0 for both the Ctrl key and letter-C key.

If the keyboard works and you can use it for other applications, then keypresscallback
really should return non-zero character code values.

I don't know pygtk, but if there are other keyboard input calls like sscanf in C, then experiment with these and see what you get.

If you know C/C++ and GCC you could try the following to inspect the keyvals:  

//  main.cpp
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

static gboolean keypresscallback ( GtkWidget * w,
                                   GdkEventKey *event,
                                   char * data )
   {
   printf ( " key PRESS val=%x state=%x\n" , event->keyval , event->state ) ;
   return false;
   }

int main ( int argc , char * argv[] )
   {
   gtk_init(&argc, &argv);

   GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
   gtk_window_set_default_size(GTK_WINDOW(window), 300 , 200);
   gtk_window_set_title(GTK_WINDOW(window), "Test Window");

   gtk_widget_add_events (window, GDK_KEY_PRESS_MASK );
   g_signal_connect ( window, "key-press-event",
                      G_CALLBACK (keypresscallback), NULL ) ;
   gtk_widget_show_all(window);

   gtk_main();
   }

Also, could you use another standard western-european keyboard to see if it behaves differently?

--- On Sun, 31/1/10, Yann Leboulanger <asterix lagaule org> wrote:

From: Yann Leboulanger <asterix lagaule org>
Subject: Re: detect ctrl+c in key_press_event handler
To: gtk-list gnome org
Date: Sunday, 31 January, 2010, 5:02 PM

Ken Resander wrote:
> I am in nearly unknown territory, since mostly I have been in the ASCII world with chars from a to z.
>
> Could you check the event.keyval for character 'C' on your keyboard and see what character code is returned. Use printf to view the value. Then use this value in the comparison instead of 'C'. Please let me know if it works ( I want to know too!).
>
> Ken

It returns 0.
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list


Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]