From 8ba4814d5fa6a4aa9b48e0b91337001f94ce098e Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Thu, 2 Feb 2023 07:55:40 -0700 Subject: [PATCH] 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 --- lib/matplotlib/backends/_backend_tk.py | 2 +- lib/matplotlib/cbook.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index 7aa24e06ff8d..e29b5a7be320 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -354,7 +354,7 @@ def _mpl_modifiers(event, *, exclude=None): ("ctrl", 1 << 2, "control"), ("alt", 1 << 4, "alt"), ("shift", 1 << 0, "shift"), - ("super", 1 << 3, "super"), + ("cmd", 1 << 3, "cmd"), ] if sys.platform == "darwin" else [ ("ctrl", 1 << 2, "control"), ("alt", 1 << 3, "alt"), diff --git a/lib/matplotlib/cbook.py b/lib/matplotlib/cbook.py index 503c5e197d77..919c6d869e5c 100644 --- a/lib/matplotlib/cbook.py +++ b/lib/matplotlib/cbook.py @@ -2169,6 +2169,9 @@ def _unikey_or_keysym_to_mplkey(unikey, keysym): key = key.replace("page_", "page") if key.endswith(("_l", "_r")): # alt_l, ctrl_l, shift_l. key = key[:-2] + if sys.platform == "darwin" and key == "meta": + # meta should be reported as command on mac + key = "cmd" key = { "return": "enter", "prior": "pageup", # Used by tk.