Hi List I am trying to figure out a way to hack keyboard input and finally I've found a similar thing in py_gtk. The method is given below.- _________________________________ def on_TextView_key_press(self, widget,event): keycode = event.hardware_keycode self.undo_manager.cur_keyval = event.keyval
# Skip if Ctrl or Alt are pressed if ('GDK_CONTROL_MASK' in event.state.value_names) \ or ('GDK_MOD1_MASK' in event.state.value_names): return False if (not self.IsLangDefault): try: # get char from the mapping if ('GDK_SHIFT_MASK' in event.state.value_names) or \ ('GDK_LOCK_MASK' in event.state.value_names): new_char = self.LayManager.dict_trans[keycode][1] else: new_char = self.LayManager.dict_trans[keycode][0] self.textbuffer.delete_selection(True, self.textview.get_editable()) self.textbuffer.insert_interactive_at_cursor(new_char, self.textview.get_editable()) except : # return unchanged keyval for unrecognized keystrokes return False # insert the new char instead return True else: return False _______________________________________________ Exactly the same thing I am trying to do in c# with gtk. So I am exprerimenting to get values of keys in another widget. I only want to ask why I am unable to catch keypress events raised by normal keys (a, b, c, d, y, 1, 2 etc etc). Modifier keys when pressed raise the event and I get the output as well. You can see the code how I am doing this. protected virtual void OnTextview1KeyPressEvent (object o, Gtk.KeyPressEventArgs args) { char key = (char)args.Event.Key; entry1.Text = key.ToString(); } There are only two widgets on window. The keypress event is raised in textview1 and its output is in entry1. I am getting output (basically strange characters) when I press shift, alt, ctrl or caps lock or num lock but normal keys are not raising events. Where I am wrong plz point out so I can correct the code?? OR IT IS A BUG IN GTK#?????? Regards -- Muhammad Shakir Aziz محمد شاکر عزیز
_______________________________________________ Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/gtk-sharp-list