Skip to content

Commit 888269f

Browse files
committed
FIX: macosx keep track of mouse up/down for cursor hand changes
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().
1 parent 61ed3f4 commit 888269f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/_macosx.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
static bool keyChangeShift = false;
4646
static bool keyChangeOption = false;
4747
static bool keyChangeCapsLock = false;
48+
/* Keep track of the current mouse up/down state for open/closed cursor hand */
49+
static bool leftMouseGrabbing = false;
4850

4951
/* -------------------------- Helper function ---------------------------- */
5052

@@ -460,7 +462,13 @@ int mpl_check_modifier(
460462
case 1: [[NSCursor arrowCursor] set]; break;
461463
case 2: [[NSCursor pointingHandCursor] set]; break;
462464
case 3: [[NSCursor crosshairCursor] set]; break;
463-
case 4: [[NSCursor openHandCursor] set]; break;
465+
case 4:
466+
if (leftMouseGrabbing) {
467+
[[NSCursor closedHandCursor] set];
468+
} else {
469+
[[NSCursor openHandCursor] set];
470+
}
471+
break;
464472
/* OSX handles busy state itself so no need to set a cursor here */
465473
case 5: break;
466474
case 6: [[NSCursor resizeLeftRightCursor] set]; break;
@@ -1521,8 +1529,10 @@ - (void)mouseDown:(NSEvent *)event
15211529
else
15221530
{
15231531
button = 1;
1524-
if ([NSCursor currentCursor]==[NSCursor openHandCursor])
1532+
if ([NSCursor currentCursor]==[NSCursor openHandCursor]) {
1533+
leftMouseGrabbing = true;
15251534
[[NSCursor closedHandCursor] set];
1535+
}
15261536
}
15271537
break;
15281538
}
@@ -1549,6 +1559,7 @@ - (void)mouseUp:(NSEvent *)event
15491559
y = location.y * device_scale;
15501560
switch ([event type])
15511561
{ case NSEventTypeLeftMouseUp:
1562+
leftMouseGrabbing = false;
15521563
button = 1;
15531564
if ([NSCursor currentCursor]==[NSCursor closedHandCursor])
15541565
[[NSCursor openHandCursor] set];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy