@@ -106,7 +106,9 @@ def CustomHandler(signum, frame):
106
106
('Key_Control' , ['AltModifier' ], 'alt+control' ),
107
107
('Key_Alt' , ['ControlModifier' ], 'ctrl+alt' ),
108
108
('Key_Aacute' , ['ControlModifier' , 'AltModifier' , 'MetaModifier' ],
109
- 'ctrl+alt+super+\N{LATIN SMALL LETTER A WITH ACUTE} ' ),
109
+ 'ctrl+alt+meta+\N{LATIN SMALL LETTER A WITH ACUTE} ' ),
110
+ # We do not currently map the media keys, this may change in the
111
+ # future. This means the callback will never fire
110
112
('Key_Play' , [], None ),
111
113
('Key_Backspace' , [], 'backspace' ),
112
114
('Key_Backspace' , ['ControlModifier' ], 'ctrl+backspace' ),
@@ -142,6 +144,7 @@ def test_correct_key(backend, qt_core, qt_key, qt_mods, answer):
142
144
Assert sent and caught keys are the same.
143
145
"""
144
146
from matplotlib .backends .qt_compat import _enum , _to_int
147
+ result = None
145
148
qt_mod = _enum ("QtCore.Qt.KeyboardModifier" ).NoModifier
146
149
for mod in qt_mods :
147
150
qt_mod |= getattr (_enum ("QtCore.Qt.KeyboardModifier" ), mod )
@@ -152,11 +155,13 @@ def key(self): return _to_int(getattr(_enum("QtCore.Qt.Key"), qt_key))
152
155
def modifiers (self ): return qt_mod
153
156
154
157
def on_key_press (event ):
155
- assert event .key == answer
158
+ nonlocal result
159
+ result = event .key
156
160
157
161
qt_canvas = plt .figure ().canvas
158
162
qt_canvas .mpl_connect ('key_press_event' , on_key_press )
159
163
qt_canvas .keyPressEvent (_Event ())
164
+ assert result == answer
160
165
161
166
162
167
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
0 commit comments