@@ -156,6 +156,8 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
156
156
(QtCore .Qt .ControlModifier , 'ctrl' , QtCore .Qt .Key_Control )
157
157
]
158
158
159
+ _ctrl_modifier = QtCore .Qt .ControlModifier
160
+
159
161
if sys .platform == 'darwin' :
160
162
# in OSX, the control and super (aka cmd/apple) keys are switched, so
161
163
# switch them back.
@@ -169,15 +171,17 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
169
171
(QtCore .Qt .AltModifier , 'alt' , QtCore .Qt .Key_Alt ),
170
172
(QtCore .Qt .MetaModifier , 'ctrl' , QtCore .Qt .Key_Meta ),
171
173
]
172
-
174
+
175
+ _ctrl_modifier = QtCore .Qt .MetaModifier
176
+
173
177
# map Qt button codes to MouseEvent's ones:
174
178
buttond = {QtCore .Qt .LeftButton : 1 ,
175
179
QtCore .Qt .MidButton : 2 ,
176
180
QtCore .Qt .RightButton : 3 ,
177
181
# QtCore.Qt.XButton1 : None,
178
182
# QtCore.Qt.XButton2 : None,
179
183
}
180
-
184
+
181
185
def __init__ ( self , figure ):
182
186
if DEBUG : print ('FigureCanvasQt: ' , figure )
183
187
_create_qApp ()
@@ -299,16 +303,15 @@ def _get_key( self, event ):
299
303
300
304
if event .key () < 256 :
301
305
key = unicode (event .text ())
302
-
303
306
# if the control key is being pressed, we don't get the correct
304
307
# characters, so interpret them directly from the event.key().
305
308
# Unfortunately, this means that we cannot handle key's case
306
- # since event.key() is not case sensitve , whereas event.text() is,
309
+ # since event.key() is not case sensitive , whereas event.text() is,
307
310
# Finally, since it is not possible to get the CapsLock state
308
311
# we cannot accurately compute the case of a pressed key when
309
312
# ctrl+shift+p is pressed.
310
- if int (event .modifiers ()) & QtCore . Qt . ControlModifier :
311
- # we always get an uppercase charater
313
+ if int (event .modifiers ()) & self . _ctrl_modifier :
314
+ # we always get an uppercase character
312
315
key = chr (event .key ())
313
316
# if shift is not being pressed, lowercase it (as mentioned,
314
317
# this does not take into account the CapsLock state)
@@ -322,7 +325,7 @@ def _get_key( self, event ):
322
325
# prepend the ctrl, alt, super keys if appropriate (sorted in that order)
323
326
for modifier , prefix , Qt_key in self ._modifier_keys :
324
327
if event .key () != Qt_key and int (event .modifiers ()) & modifier == modifier :
325
- key = '{}+{}' .format (prefix , key )
328
+ key = u '{}+{}' .format (prefix , key )
326
329
327
330
return key
328
331
0 commit comments