Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromgreglucas:macosx-cursor-hand
Jun 16, 2023

Conversation

greglucas
Copy link
Contributor

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 themouse_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

  • [-] Has pytest style unit tests (andpytest passes)
  • [-] Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • [-] New plotting related features are documented with examples.

Release Notes

  • [-] New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • [-] API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • [-] Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

@greglucasgreglucas added this to thev3.8.0 milestoneMar 25, 2023
@daniilS
Copy link
Contributor

I finally got hold of a Mac to test this on. I wanted to see how the default pan tool avoids the issue of_wait_cursor_for_draw_cm() resetting the closed hand back to the open hand - turns out that since 3.6.0, it doesn't either if you move the mouse quickly. This PR fixes that as well, though I haven't found out what caused it to break in the first place, so don't know if it's anything important.

src/_macosx.m Outdated
Comment on lines 1531 to 1516
leftMouseDown = true;
button = 1;
if ([NSCursor currentCursor]==[NSCursor openHandCursor])
[[NSCursor closedHandCursor] set];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
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.

Copy link
ContributorAuthor

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.

Copy link
Contributor

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.

Copy link
ContributorAuthor

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.

@greglucasgreglucasforce-pushed themacosx-cursor-hand branch 2 times, most recently fromb60ca42 to888269fCompareApril 7, 2023 01:21
Keep track of whether the left mouse is up or down so that we canset the proper open/closed cursor hand within set_cursor().
@greglucas
Copy link
ContributorAuthor

@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.

@jklymakjklymak merged commitf588d2b intomatplotlib:mainJun 16, 2023
@greglucasgreglucas deleted the macosx-cursor-hand branchJune 16, 2023 11:35
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@daniilSdaniilSdaniilS requested changes

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

4 participants
@greglucas@daniilS@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp