Key Press event is captured by the Window, not just the plot area.
Issue #12
resolved
No description provided.
Comments (3)
-
reporter -
reporter - changed status to resolved
At creation time of the canvas:
self.canvas.set_can_focus(True)
And in "on_click" handler (or wherever/whenever desired):
self.canvas.grab_focus()
Then the key event will be handled appropriately with either connect() or mpl_connect(). This was simpler than what is described for C.
-
reporter Could be desirable to also handle the focus_in/focus_out to show in the GUI that the drawing area has the focus:
self.canvas.connect('focus_in_event', on_focus_in) self.canvas.connect('focus_out_event', on_focus_out)
- Log in to comment
See:
http://www.benoitvidis.com/2010/05/how-to-capture-the-keypressevent-on-a-gtk-custom-widget/