8000 Improve Gtk3 backend handling of shift as a modifier · matplotlib/matplotlib@6a0ea71 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a0ea71

Browse files
Alejandro Garcíatacaswell
authored andcommitted
Improve Gtk3 backend handling of shift as a modifier
1 parent ec45ae6 commit 6a0ea71

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import functools
22
import logging
33
import os
4-
from pathlib import Path
54
import sys
5+
from pathlib import Path
66

77
import matplotlib as mpl
88
from matplotlib import _api, backend_tools, cbook
99
from matplotlib._pylab_helpers import Gcf
1010
from matplotlib.backend_bases import (
1111
_Backend, FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
1212
StatusbarBase, TimerBase, ToolContainerBase, cursors)
13-
from matplotlib.figure import Figure
14-
from matplotlib.widgets import SubplotTool
1513

1614
try:
1715
import gi
@@ -213,17 +211,21 @@ def size_allocate(self, widget, allocation):
213211
self.draw_idle()
214212

215213
def _get_key(self, event):
214+
unikey = chr(Gdk.keyval_to_unicode(event.keyval))
216215
key = cbook._unikey_or_keysym_to_mplkey(
217-
chr(Gdk.keyval_to_unicode(event.keyval)),
216+
unikey,
218217
Gdk.keyval_name(event.keyval))
219218
modifiers = [
220-
(Gdk.ModifierType.MOD4_MASK, 'super'),
221-
(Gdk.ModifierType.MOD1_MASK, 'alt'),
222-
(Gdk.ModifierType.CONTROL_MASK, 'ctrl'),
223-
]
219+
(Gdk.ModifierType.CONTROL_MASK, 'ctrl'),
220+
(Gdk.ModifierType.MOD1_MASK, 'alt'),
221+
(Gdk.ModifierType.SHIFT_MASK, 'shift'),
222+
(Gdk.ModifierType.MOD4_MASK, 'super'),
223+
]
224224
for key_mask, prefix in modifiers:
225225
if event.state & key_mask:
226-
key = '{0}+{1}'.format(prefix, key)
226+
if not (prefix == 'shift' and unikey.isprintable()):
227+
key = '{0}+{1}'.format(prefix, key)
228+
break
227229
return key
228230

229231
def configure_event(self, widget, event):

0 commit comments

Comments
 (0)
0