Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 948a26f

Browse filesBrowse files
authored
Merge pull request #30096 from QuLogic/fix-offsetbox-pick
2 parents 9cf3990 + 731f454 commit 948a26f
Copy full SHA for 948a26f

File tree

Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-1
lines changed

‎lib/matplotlib/offsetbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/offsetbox.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,9 @@ def __init__(self, ref_artist, use_blit=False):
15041504
@staticmethod
15051505
def _picker(artist, mouseevent):
15061506
# A custom picker to prevent dragging on mouse scroll events
1507-
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}
1507+
if mouseevent.name == "scroll_event":
1508+
return False, {}
1509+
return artist.contains(mouseevent)
15081510

15091511
# A property, not an attribute, to maintain picklability.
15101512
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)

‎lib/matplotlib/tests/test_offsetbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_offsetbox.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,13 @@ def test_draggable_in_subfigure():
460460
fig.canvas.draw() # Texts are non-pickable until the first draw.
461461
MouseEvent("button_press_event", fig.canvas, 1, 1)._process()
462462
assert ann._draggable.got_artist
463+
# Stop dragging the annotation.
464+
MouseEvent("button_release_event", fig.canvas, 1, 1)._process()
465+
assert not ann._draggable.got_artist
466+
# A scroll event should not initiate a drag.
467+
MouseEvent("scroll_event", fig.canvas, 1, 1)._process()
468+
assert not ann._draggable.got_artist
469+
# An event outside the annotation should not initiate a drag.
470+
bbox = ann.get_window_extent()
471+
MouseEvent("button_press_event", fig.canvas, bbox.x1+2, bbox.y1+2)._process()
472+
assert not ann._draggable.got_artist

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.