Skip to content

Annotation.contains shouldn't consider the text+arrow's joint bbox. #13708

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

Merged
merged 1 commit into from
May 5, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 18, 2019

Previously, when deferring to Text.contains, self.get_window_extent
would incorrectly use Annotation.get_window_extent. Just force it to
use Text.get_window_extent instead.

Also make Annotation obey the optional ._contains attribute.

Also renamed the parameter to Annotation.contains to mouseevent, which is consistent with Text.contains and most other contains() methods. I decided to skip the deprecation on that...

Closes #10875.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer force-pushed the annotation-contains branch 2 times, most recently from ff5afbd to 73f410b Compare March 19, 2019 13:02
@@ -2181,12 +2184,13 @@ def transform(renderer) -> Transform
else:
self.arrow_patch = None

def contains(self, event):
contains, tinfo = Text.contains(self, event)
def contains(self, mouseevent):
Copy link
Member

Choose a reason for hiding this comment

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

The change of the parameter name is an API change. While, naming of this parameter is not consistent throughout the library, I prefer not to sneek this in with the PR.

That should be handled in a separate PR and unify all contains signatures. It needs at least an API-change note (if not a @cbook._rename_parameter deprecation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted that change

Previously, when deferring to Text.contains, self.get_window_extent
would incorrectly use Annotation.get_window_extent.  Just force it to
use Text.get_window_extent instead.

Also make Annotation obey the optional `._contains` attribute.
@anntzer anntzer force-pushed the annotation-contains branch from 73f410b to c372df2 Compare May 4, 2019 21:33
@timhoffm timhoffm added this to the v3.2.0 milestone May 4, 2019
@jklymak jklymak merged commit b6c6d6c into matplotlib:master May 5, 2019
@anntzer anntzer deleted the annotation-contains branch May 5, 2019 09:46
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.

Annotation.contains and FancyArrow.contains return incorrect values
3 participants