-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: macosx keep track of mouse up/down for cursor hand changes #25548
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
I finally got hold of a Mac to test this on. I wanted to see how the default pan tool avoids the issue of |
src/_macosx.m
Outdated
leftMouseDown = true; | ||
button = 1; | ||
if ([NSCursor currentCursor]==[NSCursor openHandCursor]) | ||
[[NSCursor closedHandCursor] set]; |
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.
leftMouseDown = true; | |
button = 1; | |
if ([NSCursor currentCursor]==[NSCursor openHandCursor]) | |
[[NSCursor closedHandCursor] set]; | |
button = 1; | |
if ([NSCursor currentCursor]==[NSCursor openHandCursor]) | |
{ | |
leftMouseDown = true; | |
[[NSCursor closedHandCursor] set]; | |
} |
This avoids showing a closed hand when the click happened outside of the draggable object, or before the pan mode became 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.
Hm... I purposefully put it outside the if-branch actually because I figured if the cursor is down, we want the closed hand regardless of if we have grabbed anything or not. I can see arguments both ways, so is there a standard to follow for that kind of interaction? With this, there is an open-hand even if I have the mouse down indicating I may be able to grab something again, even though that isn't possible.
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.
MacOS documentation mentions:
- Open hand: Appears when the mouse pointer is over an item that you can move and adjust within specific bounds [...]
- Closed hand: Appears when you’re moving and adjusting an item within specific bounds [...]
hence my proposed change. To me it also seem that the closed hand should only ever appear if something is actively being dragged. The open hand with mouse down sounds fine - it means you are not currently grabbing anything, but could if you clicked again.
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.
OK, I'm sold. Updated with that behavior now.
b60ca42
to
888269f
Compare
888269f
to
da95b70
Compare
da95b70
to
05c6009
Compare
Keep track of whether the left mouse is up or down so that we can set the proper open/closed cursor hand within set_cursor().
05c6009
to
03730da
Compare
@jklymak since you've got a mac do you care to test this one out? You can run the example in the PR description to see the before/after with this change. |
PR Summary
Keep track of whether the left mouse is up or down so that we can set the proper open/closed cursor hand within set_cursor().
To test this, you can run the
mouse_cursor
example and click down and move the mouse in the "MOVE" section. Previously the cursor would be reset to the open-hand once the cursor is moved. With this update, the open/closed cursor depends on whether the left-button is depressed or not.python galleries/examples/widgets/mouse_cursor.py
Suggested by @daniilS in #25412 (comment) and this PR does help the macOS version of that PR as well.
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