I'm writing a bit of code for a Gedit plugin. I'm using Python and the interface (obviously) is GTK.
So, the issue I'm having is quite simple: I have a search box (a gtk.Entry) and right below I have a results box (a gtk.TreeView). Right after you type something in the search box you are presented a bunch of results, and I would like the user to be able to press the Up/Down keys to select one, Enter to choose it, and be done. Thing is, I can't seem to find a way to forward the Up/Down keypress to the TreeView. Currently I have this piece of code:
def __onSearchKeyPress(self, widget, event):
"""
Forward up and down keys to the tree.
"""
if event.keyval in [gtk.keysyms.Up, gtk.keysyms.Down]:
print "pressed up or down"
e = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
e.keyval = event.keyval
e.window = self.browser.window
e.send_event = True
self.browser.emit("key-press-event", e)
return True
I can clearly see I'm receiving the right kind of event, but the event I'm sending gets ignored by the TreeView. Any ideas?
Thanks in advance people.