Skip to content

Commit a364dc5

Browse files
authored
Merge pull request #29842 from dstansby/scroll-drag
2 parents 6cca7ba + 0622c25 commit a364dc5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/offsetbox.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ def finalize_offset(self):
14861486
def __init__(self, ref_artist, use_blit=False):
14871487
self.ref_artist = ref_artist
14881488
if not ref_artist.pickable():
1489-
ref_artist.set_picker(True)
1489+
ref_artist.set_picker(self._picker)
14901490
self.got_artist = False
14911491
self._use_blit = use_blit and self.canvas.supports_blit
14921492
callbacks = self.canvas.callbacks
@@ -1500,6 +1500,11 @@ def __init__(self, ref_artist, use_blit=False):
15001500
]
15011501
]
15021502

1503+
@staticmethod
1504+
def _picker(artist, mouseevent):
1505+
# A custom picker to prevent dragging on mouse scroll events
1506+
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}
1507+
15031508
# A property, not an attribute, to maintain picklability.
15041509
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)
15051510
cids = property(lambda self: [

0 commit comments

Comments
 (0)