Simplify CheckButtons and RadioButtons click handler. #26903
Merged
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.
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