Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Milestone
Description
This issue is restricted to:
- tk backend
- on OSX
self._tkcanvas.bind("<Key>",self.key_press) |
to
matplotlib/lib/matplotlib/backends/_backend_tk.py
Lines 356 to 358 in1ab4a53
defkey_press(self,event): | |
key=self._get_key(event) | |
FigureCanvasBase.key_press_event(self,key,guiEvent=event) |
to
matplotlib/lib/matplotlib/backends/_backend_tk.py
Lines 317 to 352 in1ab4a53
def_get_key(self,event): | |
unikey=event.char | |
key=cbook._unikey_or_keysym_to_mplkey(unikey,event.keysym) | |
# add modifier keys to the key string. Bit details originate from | |
# http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm | |
# BIT_SHIFT = 0x001; BIT_CAPSLOCK = 0x002; BIT_CONTROL = 0x004; | |
# BIT_LEFT_ALT = 0x008; BIT_NUMLOCK = 0x010; BIT_RIGHT_ALT = 0x080; | |
# BIT_MB_1 = 0x100; BIT_MB_2 = 0x200; BIT_MB_3 = 0x400; | |
# In general, the modifier key is excluded from the modifier flag, | |
# however this is not the case on "darwin", so double check that | |
# we aren't adding repeat modifier flags to a modifier key. | |
ifsys.platform=='win32': | |
modifiers= [(2,'ctrl','control'), | |
(17,'alt','alt'), | |
(0,'shift','shift'), | |
] | |
elifsys.platform=='darwin': | |
modifiers= [(2,'ctrl','control'), | |
(4,'alt','alt'), | |
(0,'shift','shift'), | |
(3,'super','super'), | |
] | |
else: | |
modifiers= [(2,'ctrl','control'), | |
(3,'alt','alt'), | |
(0,'shift','shift'), | |
(6,'super','super'), | |
] | |
ifkeyisnotNone: | |
# shift is not added to the keys as this is already accounted for | |
forbitmask,prefix,key_nameinmodifiers: | |
ifevent.state& (1<<bitmask)andkey_namenotinkey: | |
ifnot (prefix=='shift'andunikey): | |
key='{0}+{1}'.format(prefix,key) |
is the call chain on our side. This makes me think that the conversion is happening before it gets to us (but someone with a mac should probably verify that).
Originally posted by@tacaswell in#22681 (comment)