Use "space" for PageDown in TextView

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

 



Hi,

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

#   http://libre2.adacore.com/viewvc/trunk/gps/share/plug-ins/text_utils.py?view=markup&pathrev=131464
# and shows how to override key bindings.
SPACE=32
BACKSPACE=65288
def override (key, modifier, movement, step, select):
    gtk.binding_entry_remove (gtk.TextView, key, modifier)
    gtk.binding_entry_add_signal (gtk.TextView, key, modifier,
                                  "move_cursor",
                                  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()

tv.set_editable(False)

tv.set_cursor_visible(False)
override_key_bindings(select=False)

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?

Thanks!
Dov

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux