Re: trouble with key bindings

    Havoc> Skip Montanaro <skip pobox com> writes: 
    >> gobject.signal_new("move-obj", Sketch, gobject.SIGNAL_RUN_FIRST,

    Havoc> This needs to be SIGNAL_RUN_ACTION as well

    >> gobject.TYPE_NONE, (gobject.TYPE_INT, gobject.TYPE_INT))
    >> I want to be able to bind <ctl>- and <shift>-prefixed arrow keys to the
    >> "move-obj" signal, so I defined the following

    Havoc> You have to do GtkBindingSet stuff, look at some example
    Havoc> class_init functions in GTK.

Thanks for the feedback.  The gtkrc parsing stuff is calling
gtk_binding_entry_add_signall already, so I don't think I need to do
anything in that regard.  The addition of gobject.SIGNAL_ACTION to the
signal_new call had no effect.  I enabled signal debugging and noticed that
the key press/release events are being seen by the parent of the Sketch
object, not by the Sketch object itself.

After much fiddling, I found that if I associated the new signal with
gtk.GtkDrawingArea itself (not a Python-based subclass), made the third arg
of the signal_new SIGNAL_RUN_LAST|SIGNAL_ACTION, and called grab_focus, I
could see and handle key presses.  I'll move this to the pygtk list to see
if there's something about subclassing Gtk widgets in Python that makes them
not work quite right.

Skip Montanaro (skip pobox com)

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