[pygtk] Generating Keyboard Events

2006-03-14 Thread Chris Gonnerman
Can anyone give me some guidance on generating keyboard events?  There 
are a couple of widgets that just don't work to suit me, and which 
cannot (so far as I can tell) be directly overridden; the 
gtk.EntryCompletion is my #1 pet peeve, for how it handles Tab.  I'd 
like to catch the keystroke (which I know how to do), nullify it (which 
I think I know how to do), and generate a Return and a Tab and have them 
handled in that order (I'll need to keep a flag to prevent the synthetic 
Tab from making the whole mess loop).


But I'm not having any luck finding guidance for creating synthetic 
keyboard events.


Anybody?

-- Chris.

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Generating Keyboard Events

2006-03-14 Thread Nikos Kouremenos
On 3/14/06, Chris Gonnerman [EMAIL PROTECTED] wrote:
 Can anyone give me some guidance on generating keyboard events?  There
 are a couple of widgets that just don't work to suit me, and which
 cannot (so far as I can tell) be directly overridden; the
 gtk.EntryCompletion is my #1 pet peeve, for how it handles Tab.  I'd
 like to catch the keystroke (which I know how to do), nullify it (which
 I think I know how to do), and generate a Return and a Tab and have them
 handled in that order (I'll need to keep a flag to prevent the synthetic
 Tab from making the whole mess loop).

 But I'm not having any luck finding guidance for creating synthetic
 keyboard events.

 Anybody?


event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here
event.keyval = gtk.keysyms.Return
event.state = gtk.gdk.CONTROL_MASK
event.time = 0 # assign current time

widget_that_should_accept_signal.emit('key_press_event', event)

I put those in an FAQ
--
Nikos Kouremenos
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/