Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit948a26f

Browse files
authored
Merge pull request#30096 from QuLogic/fix-offsetbox-pick
2 parents9cf3990 +731f454 commit948a26f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎lib/matplotlib/offsetbox.py

Lines 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)andmouseevent.name!="scroll_event"), {}
1507+
ifmouseevent.name=="scroll_event":
1508+
returnFalse, {}
1509+
returnartist.contains(mouseevent)
15081510

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

‎lib/matplotlib/tests/test_offsetbox.py

Lines 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
assertann._draggable.got_artist
463+
# Stop dragging the annotation.
464+
MouseEvent("button_release_event",fig.canvas,1,1)._process()
465+
assertnotann._draggable.got_artist
466+
# A scroll event should not initiate a drag.
467+
MouseEvent("scroll_event",fig.canvas,1,1)._process()
468+
assertnotann._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+
assertnotann._draggable.got_artist

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp