GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't drag draggables on scroll events by dstansby · Pull Request #29842 · matplotlib/matplotlib

Conversation

@dstansby

@dstansby dstansby commented Mar 31, 2025

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

  • "closes #0000" is in the body of the PR description to link the related issue
  • new and changed code is tested
  • Plotting related features are demonstrated in an example
  • New Features and API Changes are noted with a directive and release note
  • Documentation complies with general and docstring guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dstansby
Don't drag draggables on scroll events
29e7d8d
@tacaswell tacaswell added this to the v3.10.2 milestone Mar 31, 2025
tacaswell
tacaswell approved these changes Mar 31, 2025
View reviewed changes
@dstansby
Move picker to method
c77e9d5
@timhoffm

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tacaswell

tacaswell commented Apr 1, 2025

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@timhoffm

timhoffm commented Apr 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dstansby

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timhoffm
timhoffm approved these changes Apr 2, 2025
View reviewed changes

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Anybody can merge after adding the suggested documentation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/matplotlib/offsetbox.py

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

@timhoffm timhoffm Apr 2, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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"), {}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dstansby dstansby Apr 2, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

👍 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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

timhoffm reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
dstansby
dstansby commented Apr 2, 2025
View reviewed changes
Comment thread lib/matplotlib/offsetbox.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@dstansby
Add comment to new method
0622c25
@timhoffm
timhoffm merged commit a364dc5 into matplotlib:main Apr 2, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 2, 2025
@timhoffm @meeseeksmachine
Backport PR matplotlib#29842: Don't drag draggables on scroll events
b29bd15
@meeseeksmachine meeseeksmachine mentioned this pull request Apr 2, 2025
Backport PR #29842 on branch v3.10.x (Don't drag draggables on scroll events) #29858
Merged
@dstansby
dstansby deleted the scroll-drag branch April 2, 2025 18:42
@dstansby dstansby mentioned this pull request Apr 2, 2025
Prevent draggable legend from being stuck after scroll event #29270
Closed
@ksunden ksunden mentioned this pull request May 9, 2025
merge up 3.10.3 #30031
Closed
5 tasks
@ksunden ksunden mentioned this pull request Jul 25, 2025
Manual Backport PR #30195 on branch v3.10.x (ci: Enable wheel builds on Python 3.14) #30356
Merged
5 tasks
@ksunden ksunden mentioned this pull request Aug 7, 2025
merge up v3.10.5 #30401
Merged
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tacaswell tacaswell tacaswell approved these changes
@timhoffm timhoffm timhoffm approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v3.10.3

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@dstansby @timhoffm @tacaswell
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.