Skip to content

ENH/MacOS Allow shift modifiers to key events #9836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2017

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Nov 22, 2017

PR Summary

#9835 points out that "shift-left" etc not allowed for macOS. This PR fixes that by allowing a
shift modifier if the other key is a special key...

To test, use the script by the OP:

import matplotlib.pyplot as plt
fig = plt.figure()

def on_key(event):
    print('you pressed', event.key, event.xdata, event.ydata)

fig.canvas.mpl_connect('key_press_event', on_key)
plt.show()

PR Checklist

  • [N/A] Has Pytest style unit tests
  • [N/A] Code is PEP 8 compliant

@cbrnr
Copy link
Contributor

cbrnr commented Nov 23, 2017

I don't have a dev env set up yet, but this looks super nice! Thanks a lot!

@cbrnr
Copy link
Contributor

cbrnr commented Nov 23, 2017

I can't test this because my figs do not get focus - every key I type goes directly to the terminal... This happens only when using conda (it works with Python installed via Homebrew, I'll try to setup a virtualenv there).

@cbrnr
Copy link
Contributor

cbrnr commented Nov 23, 2017

cf #9839

@cbrnr
Copy link
Contributor

cbrnr commented Nov 23, 2017

@jklymak do I need to do anything in addition to python -mpip install .? In my example, shift combinations are still not detected.

@tacaswell tacaswell added this to the v2.2 milestone Nov 23, 2017
@dstansby
Copy link
Member

That should work - what does print(matplotlib.__version__) output?

@cbrnr
Copy link
Contributor

cbrnr commented Nov 28, 2017

'2.1.0'

but

conda list matplotlib:

matplotlib                2.0.2+5783.g6284e1298           <pip>

@dstansby
Copy link
Member

That's odd... maybe try conda uninstall matplotlib and pip uninstall matplotlib and trying installing from source again.

@cbrnr
Copy link
Contributor

cbrnr commented Nov 28, 2017

For some reason, I was using pythonw from my main Anaconda env even though I activated another env for building your matplotlib version. Installing Python.app explicitly in the env solved this issue.

And yes, your fix is working! Thanks a lot! Now if only Anaconda made the framework thing the default with their packages it would also work on macOS out of the box (but this is not related to matplotlib).

@dopplershift dopplershift merged commit 96ac97c into matplotlib:master Nov 28, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
@jklymak jklymak deleted the mac-allow-shift branch March 5, 2019 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants