-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Set the canvas cursor when using a SpanSelector #20743
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
Agreed, I don't think it's worth the pain. |
lib/matplotlib/widgets.py
Outdated
return | ||
|
||
if self._active_handle is not None: | ||
# Do nothing if button is pressed and a handle is active. |
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'm not really sure what this case is supposed to handle?
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.
When you're dragging, the cursor stays as the resizer. If you're dragging and move close enough to an edge before the selector moves, then it could trigger the hover effect and disable the resize cursor even though the selector is still active. I think this may only apply if you are dragging from the centre.
A simple check for if you remove this bit: start dragging within an existing span, but just a little outside the grab range, the cursor will be a resize. If you move towards the handle and back again (might need to do this quick-ish), it will revert back to a pointer.
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.
Ah, I see, perhaps just add a comment to note that this is to handle draw_from_anywhere=True
? (which I had missed)
I can't repro it locally but I guess that depends on mouse latency.
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.
Yes, I'm using X forwarding (though still on the local network), so there may be some delay between events.
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.
It raises an error when it is used with interactive=False
:
File "/home/eric/Dev/others/matplotlib/lib/matplotlib/widgets.py", line 2298, in _hover
_, e_dist = self._edge_handles.closest(event.x, event.y)
AttributeError: 'SpanSelector' object has no attribute '_edge_handles'
Would it be possible/make sense to add it to the base class (_SelectorWidget
), so it can be used by the RectangleSelector
?
It seems that there is no REZISE_DIAGONALE
in the Cursors
class, so it may not work very well. In any case, it may not be necessary neither because, the RectangleSelector
has marker as handle and it is clear visual indicator that it can be use to resize the selector!
This sets either a horizontal or vertcal resize cursor when initiating a selection, moving the span, or when hovering over an end handle.
The I've fixed the other two issues. |
Yes, indeed! |
Yes, I may still do that one, but need to experiment a bit to see how easy it is. |
PR Summary
This sets either a horizontal or vertcal resize cursor when initiating a selection, moving the span, or when hovering over an end handle.
This is half of #20724.
I said I was going to move things to
ToolLineHandles
, but there are two reasons why I didn't:grab_range
, which is needed for determining when we're hovering.I could propagate the information over, but seemed like more work than just handling the cursor entirely in the
SpanSelector
widget. I could finish moving it if we think that makes a better design.PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).