I'd like to be able to use emacs-like keybindings in an text entry
widget, specifically <ctrl>a for beginning of line and <ctrl>e for end
of line.
I've tried the following:
keytext=gtk.Entry()
keytext.set_text("a test")
keytext.connect("key_press_event", self.emacstext)
def emacstext(self, widget, event,*args):
key = event.keyval
if key < 256:
if event.state & CONTROL_MASK:
if chr(key) == 'a':
widget.set_position(0)
elif chr(key) == 'z':
widget.set_position(0)
elif chr(key) == 'e':
widget.set_position(-1)
This works for <ctrl>e and <ctrl>z, but <ctrl>a still does a select-all
instead. Is it possible to override the built-in key bindings? Is it
even possible to view them? Is there a better way to do this?
I've looked in the FAQ and the reference pages, but I haven't found
anything that works.
Regards,
Chris
-----------------------------------------------------------------
Chris Rouch
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/