[Sugar-devel] How to make a GTK3 EventBox accept the focus?

Manuel Quiñones manuq at laptop.org
Mon Feb 25 07:20:41 EST 2013


Hi James,

2013/2/24 James Simmons <nicestep at gmail.com>:
> I was looking at the upgrade to GTK3 done for View Slides and it seems that
> it no longer responds to the keyboard.  What I had done previously to get it
> to do that was to put the image I was displaying in an event box.  I then
> made the event box accept the focus like this:
>
> self.eventbox.set_events(gtk.gdk.KEY_PRESS_MASK | gtk.gdk.BUTTON_PRESS_MASK)
> self.eventbox.set_flags(gtk.CAN_FOCUS)
>
> The Gtk3 port changed the code to this:
>
> self.eventbox.set_events(Gdk.EventMask.KEY_PRESS_MASK |
> Gdk.EventMask.BUTTON_PRESS_MASK)
>
> There was no code to make it accept the focus.  I tried adding this:
>
> self.eventbox.set_can_focus(True)
>
> This does not prevent the Activity from running, but it doesn't make the
> Event Box focusable either.

Have you tried self.eventbox.grab_focus() ?

http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-grab-focus

-- 
.. manuq ..


More information about the Sugar-devel mailing list