On Sun, Dec 14, 2003 at 05:46:22PM -0600, John Hunter wrote:
>
> I want the behavior of a button to be different depending on whether a
> modifier key is pressed when that button is pressed. I haven't
> succeeded yet in capturing the keys pressed. The bottom lives in a
> gtk.Toolbar.
>
> I have tried various incantations suggested by the FAQ, eg, using an
> event box, to no avail
Have you tried putting the eventbox *around* the Toolbar? You would at
least find out if the Toolbar isn't capturing and blocking the
propagation of the signal. It's perhaps a bit odd, but I don't know how
the Toolbar works, and I can give you a hint -- I couldn't get toolbar
buttons to accept mnemonics, either.
If your eventbox doesn't get the key_press_event, does your toplevel
window get it?
> iconw = gtk.Image()
> iconw.set_from_stock(gtk.STOCK_GO_BACK, iconSize)
> self.bLeft = self.append_item(
> 'Left',
> 'Move back in time',
> 'Private',
> iconw,
> self.panx,
> 0)
>
> def key_press(widget, key):
> print 'press', key
>
> def key_release(widget, key):
> print 'release', key
>
> ebox = gtk.EventBox()
> ebox.add(self.bLeft)
> ebox.add_events(gdk.KEY_PRESS_MASK|gdk.KEY_RELEASE_MASK)
> self.bLeft.add_events(gdk.KEY_PRESS_MASK|gdk.KEY_RELEASE_MASK)
> self.bLeft.connect("scroll_event", self.panx)
> ebox.connect("key_press_event", key_press)
> ebox.connect("key_release_event", key_release)
>
> The 'scroll_event' works with no extra schenanigans, but I am not
> getting any key_press or key_release events.
Do you get button_press_event, at least? You can try checking in its
event object if it has anything useful set for you..
Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/