Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #29842 on branch v3.10.x (Don't drag draggables on scroll events) #29858

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ def finalize_offset(self):
def __init__(self, ref_artist, use_blit=False):
self.ref_artist = ref_artist
if not ref_artist.pickable():
ref_artist.set_picker(True)
ref_artist.set_picker(self._picker)
self.got_artist = False
self._use_blit = use_blit and self.canvas.supports_blit
callbacks = self.canvas.callbacks
Expand All @@ -1502,6 +1502,11 @@ def __init__(self, ref_artist, use_blit=False):
]
]

@staticmethod
def _picker(artist, mouseevent):
# A custom picker to prevent dragging on mouse scroll events
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}

# A property, not an attribute, to maintain picklability.
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)
cids = property(lambda self: [
Expand Down
Loading