Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 914c910

Browse files
committed
Fix help window on GTK.
Apparently, `MouseButton`s are now included, which need to be skipped.
1 parent 2333c63 commit 914c910

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,15 @@ def _normalize_shortcut(self, key):
824824

825825
return ''.join(mods) + key
826826

827+
def _is_valid_shortcut(self, key):
828+
"""
829+
Check for a valid shortcut to be displayed.
830+
831+
- GTK will never send 'cmd+' (see `FigureCanvasGTK3._get_key`).
832+
- The shortcut window only shows keyboard shortcuts, not mouse buttons.
833+
"""
834+
return 'cmd+' not in key and not key.startswith('MouseButton.')
835+
827836
def _show_shortcuts_window(self):
828837
section = Gtk.ShortcutsSection()
829838

@@ -844,8 +853,7 @@ def _show_shortcuts_window(self):
844853
accelerator=' '.join(
845854
self._normalize_shortcut(key)
846855
for key in self.toolmanager.get_tool_keymap(name)
847-
# Will never be sent:
848-
if 'cmd+' not in key),
856+
if self._is_valid_shortcut(key)),
849857
title=tool.name,
850858
subtitle=tool.description)
851859
group.add(shortcut)

0 commit comments

Comments
 (0)