Skip to content
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

Double-click events are not recognised #261

Closed
ianhi opened this issue Sep 6, 2020 · 2 comments · Fixed by #446
Closed

Double-click events are not recognised #261

ianhi opened this issue Sep 6, 2020 · 2 comments · Fixed by #446

Comments

@ianhi
Copy link
Collaborator

ianhi commented Sep 6, 2020

Originally posted by @nvaytet in matplotlib/matplotlib#18404

Posting here because ipympl will not automatically inherit whatever solution gets implemented for nbagg

Bug report

Bug summary

Using the first example from the events documentation detects double-click events properly in the Qt backend, but when used in a Jupyter notebook, the two clicks are recognised as two separate single click events.

Code for reproduction

I've adapted the code to show the contents of the event as the figure title instead of a print statement, because the output of print statements inside functions triggered by events disappear in Jupyter notebooks.

import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))

def onclick(event):
    ax.set_title('%s click: button=%d, x=%d, y=%d, xdata=%f, ydata=%f' %
          ('double' if event.dblclick else 'single', event.button,
           event.x, event.y, event.xdata, event.ydata))

cid = fig.canvas.mpl_connect('button_press_event', onclick)

Actual outcome

The title always says single-click, no matter how fast I do my double-clicking.

Screenshot at 2020-09-04 08-02-20

The double click events are properly captured when using the standard Qt window renderer.
I have tried both the default %matplotlib notebook backend and the ipympl widget backend, and they show identical behaviour.

Matplotlib version

* Operating system: Ubuntu 20.04

* Matplotlib version: 3.2.2

* Matplotlib backend (`print(matplotlib.get_backend())`): nbAgg, ipympl

* Python version: 3.7.6

* Jupyter version (if applicable): jupyter_client=6.1.6, jupyter_core=4.6.3, notebook=6.0.3

* Other libraries:

Installed in a conda env from conda-forge.

@nvaytet
Copy link

nvaytet commented Mar 31, 2022

Is there any update on this? It has been fixed in nbagg for a while.
Thanks!

@ianhi
Copy link
Collaborator Author

ianhi commented Apr 13, 2022

Should be released as 0.9.0 now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants