matplotlib/matplotlib — pull request #718 by jdh2358 (2012-02-26 17:04:51+00:00)
Title: make StrongFocus the default qt focus policy so you don't have to click to process events

This pull request addresses issue https://github.com/matplotlib/matplotlib/issues/525 which points out that in qt you have to click to process key events. By setting the focus policy to StrongFocus rather than ClickFocus according to the qt docs, you get the focus from either tab events or click events http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#focusPolicy-prop. Setting StrongFocus does enable mpl windows to process KeyEvents when the window is raised but not clicked in qt4.

While testing this patch, I explored the behavior of tkagg and gtkagg on ubuntu. What I found is that key events are processed w/o clicking (eg 's' raises the Save dialog). But even if the mouse happens to be over the axes when the window is raised, the axes specific key events are not processed (like 'g' or 'l'). If you move the mouse to trigger a motion_notify_event, even w/o clicking, the axes events will be processed. I am going to dig deeper into the event code to figure out why the inaxes code is not working in this case