Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
static bool keyChangeShift = false;
static bool keyChangeOption = false;
static bool keyChangeCapsLock = false;
/* Keep track of the current mouse up/down state for open/closed cursor hand */
static bool leftMouseGrabbing = false;

/* -------------------------- Helper function ---------------------------- */

Expand Down Expand Up @@ -457,7 +459,13 @@ int mpl_check_modifier(
case 1: [[NSCursor arrowCursor] set]; break;
case 2: [[NSCursor pointingHandCursor] set]; break;
case 3: [[NSCursor crosshairCursor] set]; break;
case 4: [[NSCursor openHandCursor] set]; break;
case 4:
if (leftMouseGrabbing) {
[[NSCursor closedHandCursor] set];
} else {
[[NSCursor openHandCursor] set];
}
break;
/* OSX handles busy state itself so no need to set a cursor here */
case 5: break;
case 6: [[NSCursor resizeLeftRightCursor] set]; break;
Expand Down Expand Up @@ -1503,8 +1511,10 @@ - (void)mouseDown:(NSEvent *)event
else
{
button = 1;
if ([NSCursor currentCursor]==[NSCursor openHandCursor])
if ([NSCursor currentCursor]==[NSCursor openHandCursor]) {
leftMouseGrabbing = true;
[[NSCursor closedHandCursor] set];
}
}
break;
}
Expand All @@ -1531,6 +1541,7 @@ - (void)mouseUp:(NSEvent *)event
y = location.y * device_scale;
switch ([event type])
{ case NSEventTypeLeftMouseUp:
leftMouseGrabbing = false;
button = 1;
if ([NSCursor currentCursor]==[NSCursor closedHandCursor])
[[NSCursor openHandCursor] set];
Expand Down