-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: Draggable legend gets stuck on cursor after scroll event #29142
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
Comments
Perhaps related to #29066 too? |
I am not sure to be honest. I don't know much about the backends. But the problem described doesn't appear to be the same. In fact I tried implementing my solution inside offsetbox.py and it worked as predicted. Scroll events no longer make legend stick to cursor. This is the proposed modification (first 3 lines of DraggableBase.on_pick): def on_pick(self, evt):
# Return if mouseevent is a scroll (this is the modification)
if evt.mouseevent.button in ('up','down'):
return
if self._check_still_parented() and evt.artist == self.ref_artist:
self.mouse_x = evt.mouseevent.x
self.mouse_y = evt.mouseevent.y
self.got_artist = True
if self._use_blit:
self.ref_artist.set_animated(True)
self.canvas.draw()
self.background = \
self.canvas.copy_from_bbox(self.ref_artist.figure.bbox)
self.ref_artist.draw(
self.ref_artist.figure._get_renderer())
self.canvas.blit()
self.save_offset() |
Oh, I see. OK, I agree your proposed patch seems reasonable (perhaps rather check |
Hi can I work on solving this issue? |
Is the thread author responsible for giving permission? If so, yes. |
Summary
Draggable legend gets stuck to cursor after scrolling while hovering the artist. To 'unstick' it, it is necessary to left click. I believe the expected behavior is to only drag the legend while holding the left mouse button. If that is not the case, please close this issue.
Proposed fix
Sample code:
I believe the issue is that the class
DraggableBase
(at line 1425 of matplotlib/offsetbox.py) uses a 'pick' event to grab the artist, which I believe includes scrolling events. It might be possible to return from a false positive pick by checking that the pick event is a mouse click instead of scrolling atDraggableBase.on_pick
. Another alternative is to change the pick event to abutton_press
event.The text was updated successfully, but these errors were encountered: