Skip to content
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

Simplify CheckButtons and RadioButtons click handler. #26903

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 24, 2023

Shorten the code that determines which button has been clicked.

Use Text.contains directly (it calls text.get_window_extent itself) rather than manually going through text.get_window_extent.

The previous code for finding the closest click was actually wrong (transAxes.inverted().transform((event.x, event.y)) is in axes space, but get_offset_transform().transform(get_offsets()) is in screen space, so they cannot be subtracted from one another) but it didn't really matter because a click is, in practice, always contained by a single button anyways (idxs has length at most 1). Still, fix that.

PR summary

PR checklist

Shorten the code that determines which button has been clicked.

Use Text.contains directly (it calls text.get_window_extent itself)
rather than manually going through text.get_window_extent.

The previous code for finding the closest click was actually wrong
(transAxes.inverted().transform((event.x, event.y)) is in axes space,
but get_offset_transform().transform(get_offsets()) is in screen space,
so they cannot be subtracted from one another) but it didn't really
matter because a click is, in practice, always contained by a single
button anyways (idxs has length at most 1).  Still, fix that.
@QuLogic QuLogic added this to the v3.9.0 milestone Sep 26, 2023
@QuLogic QuLogic merged commit d60de5e into matplotlib:main Sep 26, 2023
42 of 43 checks passed
@anntzer anntzer deleted the wc branch September 26, 2023 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants