Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54b105b

Browse filesBrowse files
authored
Merge pull request #20868 from tacaswell/fix_qt_key_mods
2 parents af68218 + 86be6bc commit 54b105b
Copy full SHA for 54b105b

File tree

1 file changed

+7
-2
lines changed
Filter options

1 file changed

+7
-2
lines changed

‎lib/matplotlib/tests/test_backend_qt.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_qt.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ def CustomHandler(signum, frame):
106106
('Key_Control', ['AltModifier'], 'alt+control'),
107107
('Key_Alt', ['ControlModifier'], 'ctrl+alt'),
108108
('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
110112
('Key_Play', [], None),
111113
('Key_Backspace', [], 'backspace'),
112114
('Key_Backspace', ['ControlModifier'], 'ctrl+backspace'),
@@ -142,6 +144,7 @@ def test_correct_key(backend, qt_core, qt_key, qt_mods, answer):
142144
Assert sent and caught keys are the same.
143145
"""
144146
from matplotlib.backends.qt_compat import _enum, _to_int
147+
result = None
145148
qt_mod = _enum("QtCore.Qt.KeyboardModifier").NoModifier
146149
for mod in qt_mods:
147150
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))
152155
def modifiers(self): return qt_mod
153156

154157
def on_key_press(event):
155-
assert event.key == answer
158+
nonlocal result
159+
result = event.key
156160

157161
qt_canvas = plt.figure().canvas
158162
qt_canvas.mpl_connect('key_press_event', on_key_press)
159163
qt_canvas.keyPressEvent(_Event())
164+
assert result == answer
160165

161166

162167
@pytest.mark.backend('QtAgg', skip_on_importerror=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.