FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Don't drag draggables on scroll events by dstansby · Pull Request #29842 · matplotlib/matplotlib · GitHub

Don't drag draggables on scroll events - #29842

Merged
timhoffm merged 3 commits into
matplotlib:mainfrom
dstansby:scroll-drag
Apr 2, 2025
Merged

Don't drag draggables on scroll events#29842
timhoffm merged 3 commits into
matplotlib:mainfrom
dstansby:scroll-drag

Conversation

Copy link
Copy Markdown
Member

PR summary

Fixes #29142; replaces #29270. The solution here is to set a custom picker on DraggableBase that doesn't fire if the event is a scroll event.

PR checklist

tacaswell added this to the v3.10.2 milestone Mar 31, 2025

timhoffm commented Apr 1, 2025

Copy link
Copy Markdown
Member

Why do we need a custom picker / why does the regular picker fire on scroll events? Should it be fixed generally on the regular picker?

Copy link
Copy Markdown
Member

A scroll event comes in looking just like a button press (but with a higher number). It does not seem unreasonable to allow these to trigger pick events in general but to disable them for draggable things specifically.

timhoffm commented Apr 1, 2025
edited
Loading

Copy link
Copy Markdown
Member

I don't think I understand this: "Pick" is logically selecting an element by clicking on it. No matter the technical implementation, why should scrolling ever be interpreted as pick? In what use case would that make sense?

dstansby commented Apr 1, 2025

Copy link
Copy Markdown
Member Author

pick is possibly an unfortunate choice of language. As an example of a picker that uses scroll, if I wanted to make an artist change size if the mouse is over it and scrolled, then giving a custom function to Artist.set_picker() would be the way to do this.

timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Anybody can merge after adding the suggested documentation.


@staticmethod
def _picker(artist, mouseevent):
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}
"""
A custom picker to prevent dragging on scroll events.
Dragging is initialized through a pick events, which is typically a
mouse click. However, mouse scrolling also fires pick events and
we need to filter them out so that scrolling does not initalize
dragging.
"""
return (artist.contains(mouseevent) and mouseevent.name != "scroll_event"), {}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👍 to adding a comment - I thought this was a bit verbose for a private helper function, so I added a one-liner instead - what do you think?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNT]: Draggable legend gets stuck on cursor after scroll event

3 participants


Back | FazBrowse Home | New Git URL