Use "space" for PageDown in TextView


I'm trying to write a simple text reading application with the TextView widget. As I am only doing reading I would like to rebind the space bar to do page down. But I can't get it to work. Here's what I did (in Python):

# The following code is taken from

# and shows how to override key bindings.
def override (key, modifier, movement, step, select):
    gtk.binding_entry_remove (gtk.TextView, key, modifier)
    gtk.binding_entry_add_signal (gtk.TextView, key, modifier,
                                  gobject.TYPE_ENUM, movement,
                                  gobject.TYPE_INT,  step,
                                  gobject.TYPE_BOOLEAN, select)
def override_key_bindings (select):
    """Override the default TextView keybinding to either always force
       the extension the selection, or not"""
    override (SPACE,        0, gtk.MOVEMENT_PAGES, 1, select)
    override (BACKSPACE,    0, gtk.MOVEMENT_PAGES, -1, select)


tv = gtk.TextView()



What seems to happen is that in addition to my SPACE binding another binding for space is being triggered. If I e.g. select part of the text in the widget and press SPACE, then the widget is scrolled such that the selected text is visible. So the question seems to be why does binding_entry_remove() not clear the default binding for space?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]