You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check pressed mouse buttons in pan/zoom drag haandlers.
Sometimes, the mouse_release_event ending a pan/zoom can be lost, if it
occurs while the canvas does not have focus (a typical case is when a
context menu is implemented on top of the canvas, see example below);
this can result in rather confusing behavior as the pan/zoom continues
which no mouse button is pressed. To fix this, always check that the
correct button is still pressed in the motion_notify_event handlers.
To test, use e.g.
```
from matplotlib import pyplot as plt
from matplotlib.backends.qt_compat import QtWidgets
def on_button_press(event):
if event.button != 3: # Right-click.
return
menu = QtWidgets.QMenu()
menu.addAction("Some menu action", lambda: None)
menu.exec(event.guiEvent.globalPosition().toPoint())
fig = plt.figure()
fig.canvas.mpl_connect("button_press_event", on_button_press)
fig.add_subplot()
plt.show()
```
enter pan/zoom mode, right-click to open the context menu, exit the
menu, and continue moving the mouse.
0 commit comments