Not getting key-press-event in Gtk.TreeView

I have a treeview in my program that does not get key-press-event when I click an arrow key (up or down), but it does get key-release-event. However, the selection moves on key-press. I do get key-press-event when I press a letter key.

In the test program I intended to include in this posting to illustrate the problem, I do get the key-press-event (and the key-release-event) when I press an arrow key, but the selection does not change.

I suppose I must have configured the TreeView in my program differently from the TreeView in my test program, but since I did not do so intentionally I have no idea what to look for. The mask is set to Structure, but I think the mask is not relevant since I do get key-release-event. It seems as if the handler that is moving the selection is stifling the event, but I do not know what I did to enable that handler in my program but not in the test program.

I would like to use the arrow keys to reorder rows in the TreeView – ctrl-UpArrow and ctrl-DownArrow to move a row up or down.

Events like key-press-event and their callbacks work by propagating the signal through the widget tree, until a callback returns TRUE indicating that is taking “ownership” of handling the event.

You don’t have to return TRUE to do something with an event, but it seems likely another widget in the hierarchy is, thus the signal emission stops propagating before it reaches your GtkTreeView.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.