-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Undeprecate Cursor event handlers #25129
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
Conversation
This reverts commit d2a3266.
So that the cursors show up on online docs
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.
I am convinced by the observation that as soon as the mouse is moved into the axes the cursor will be made visible again and already becomes invisible if the mouse moves out.
While there is a risk of breakage here, I think that it is less this way than with what is on main now.
d0af10f
to
d8f7072
Compare
Co-authored-by: Thomas A Caswell <tcaswell@gmail.com>
d8f7072
to
17542db
Compare
The current state works for me running |
Trying to run the example prior to the PR would result in exceptions being thrown on mouse moves. Manual backport of matplotlib#25106 rolled into backport of matplotlib#25129 (backport pr matplotlib#25160)
…129-on-v3.7.x Backport PR #25129 on branch v3.7.x (Undeprecate Cursor event handlers)
Closes #25107
PR Summary
The event handlers were deprecated for mpl 3.7 in #19763 (with correction for the deprecation notices in #24750)
This has not been released as a final matplotlib version (only the rc).
However, one of examples demonstrated subclassing these classes specifically to override these methods.
The callbacks registered internally were for the privitized version of the functions, thus the overrides did nothing.
Given that it is suggested in our docs, we determiened in #25107 that we should undeprecate these methods.
The original PR kept the calls to
set_visible(False)
in the un-prefixed versions ofclear
forCursor
andMultiCursor
.Because clear is registered as a callback on a
draw
event, this was causing the cursor to disappear on the nbagg backend.clear
is not actually run in our test suite, as observed on codecov.In ad hoc testing, removing seemed to have limited impact on the qt backend (seemed to function as expected).
The problem from #19763 was reintroduced for the nbagg backend if the
set_visible(False)
was included.So I removed those lines entirely for the undeprecation.
This feels odd, as I may have expected the
clear
function to explicitly turn off the cursor visibility.But as far as I can tell, it works like I'd expect.
I suspect in the narrow case of a user calling
clear
directly (as opposed to relying on the internal callbacks)it may not actually remove the lines and thus be unexpected behavior.
But I have no examples of doing such, and in most cases if the cursor was showing to begin with, the mouse is over the axes, and will cause the cursor to show up as soon as it moves anyway, I'd think.
Anywho, while working on these, figured I'd also add a simulted mouse event to the examples so that the docs show what they actually do (if not interactively still) a bit more.
I did so using
_process()
on theMouseEvent
because that is what is done in our tests for simulating mouse events.I could have made the mouse event and passed it directly to the callback method, I think, which would have avoided using an
_
method in our example.@anntzer suggested perhaps removing the widgets/annotated_cursor example all together because event_handlers/cursor_demo does effectively the same thing but in less code.
@tacaswell voted in favor of keeping both for the time being (though did check that they are cross linked to each other).
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst