Skip to content

Commit 8ba4814

Browse files
committed
FIX: Correctly report command keypress on mac for Tk + Gtk
Tk and Gtk reported "super" when "command" was pressed, while qt and macosx reported "cmd". Make all backends consistent by reporting "cmd" in all of them. @co-authored-by: Antony Lee <[email protected]>
1 parent f3938be commit 8ba4814

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _mpl_modifiers(event, *, exclude=None):
354354
("ctrl", 1 << 2, "control"),
355355
("alt", 1 << 4, "alt"),
356356
("shift", 1 << 0, "shift"),
357-
("super", 1 << 3, "super"),
357+
("cmd", 1 << 3, "cmd"),
358358
] if sys.platform == "darwin" else [
359359
("ctrl", 1 << 2, "control"),
360360
("alt", 1 << 3, "alt"),

lib/matplotlib/cbook.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,9 @@ def _unikey_or_keysym_to_mplkey(unikey, keysym):
21692169
key = key.replace("page_", "page")
21702170
if key.endswith(("_l", "_r")): # alt_l, ctrl_l, shift_l.
21712171
key = key[:-2]
2172+
if sys.platform == "darwin" and key == "meta":
2173+
# meta should be reported as command on mac
2174+
key = "cmd"
21722175
key = {
21732176
"return": "enter",
21742177
"prior": "pageup", # Used by tk.

0 commit comments

Comments
 (0)