Skip to content

Middle click event is reported as right click #254

Description

@ianhi

Describe the issue

If you middle click on an ipympl canvas the event will be reported with mousebutton.RIGHT instead of MIDDLE.

import ipywidgets as widget
import matplotlib.pyplot as plt
%matplotlib widget

out = widgets.Output()
@out.capture()
def callback(event):
    print(event.button)
    
plt.ioff(); fig,ax = plt.subplots(); plt.ion()
fig.canvas.mpl_connect('button_press_event', callback)
fs = 15
ax.text(0.1,0.1,'left click here', fontsize=fs)
ax.text(0.5,0.5,'middle click here', fontsize=fs)
ax.text(0.7,0.8,'right click here', fontsize=fs)
widgets.HBox([out,fig.canvas])

In the notebook:
jupyter

vs from ipython:
ipython

Versions

 3.8.5 (default, Aug  3 2020, 16:08:50) 
[GCC 7.3.0]
ipympl version: 0.5.7
jupyter core     : 4.6.3
jupyter-notebook : 6.1.1
qtconsole        : not installed
ipython          : 7.17.0
ipykernel        : 5.3.4
jupyter client   : 6.1.6
jupyter lab      : 2.2.2
nbconvert        : 5.6.1
ipywidgets       : 7.5.1
nbformat         : 5.0.7
traitlets        : 4.3.3
Known nbextensions:
  config dir: /home/ian/anaconda3/envs/micro/etc/jupyter/nbconfig
    notebook section
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      nbdime/index  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
JupyterLab v2.2.2
Known labextensions:
   app dir: /home/ian/anaconda3/envs/micro/share/jupyter/lab
        @axlair/jupyterlab_vim v0.12.4  enabled  OK
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyterlab/git v0.20.0  enabled  OK
        @telamonian/theme-darcula v2.0.0  enabled  OK
        jupyter-matplotlib v0.7.3  enabled  OK
        jupyterlab_vim-system-clipboard-support v0.2.0  enabled  OK
        nbdime-jupyterlab v2.0.0  enabled  OK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions