Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2d62b1

Browse files
committed
set StrongFocus as the default qt focus policy so tab/click/raise will give the canvas the focus (process events w/o clicking)
1 parent 1cd07a6 commit c2d62b1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_qt4.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,13 @@ def __init__( self, canvas, num ):
317317
image = os.path.join( matplotlib.rcParams['datapath'],'images','matplotlib.png' )
318318
self.window.setWindowIcon(QtGui.QIcon( image ))
319319

320-
# Give the keyboard focus to the figure instead of the manager
321-
self.canvas.setFocusPolicy( QtCore.Qt.ClickFocus )
320+
# Give the keyboard focus to the figure instead of the
321+
# manager; StrongFocus accepts both tab and click to focus and
322+
# will enable the canvas to process event w/o clicking.
323+
# ClickFocus only takes the focus is the window has been
324+
# clicked
325+
# on. http://developer.qt.nokia.com/doc/qt-4.8/qt.html#FocusPolicy-enum
326+
self.canvas.setFocusPolicy( QtCore.Qt.StrongFocus )
322327
self.canvas.setFocus()
323328

324329
QtCore.QObject.connect( self.window, QtCore.SIGNAL( 'destroyed()' ),

0 commit comments

Comments
 (0)