Skip to content

Commit

Permalink
Implement right mouse click on OS X when pressing control + click. This
Browse files Browse the repository at this point in the history
restores the previous mouse behaviour as found in LWJGL 2.8.5 and below.
  • Loading branch information
kappaOne committed Oct 28, 2013
1 parent 46cbd89 commit 43a6a8b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/native/macosx/org_lwjgl_opengl_Display.m
Expand Up @@ -57,6 +57,9 @@

static MacOSXPeerInfo *peer_info;

static bool leftMouseDown = false;
static bool rightMouseDown = false;

@implementation MacOSXKeyableWindow

+ (void) createWindow {
Expand Down Expand Up @@ -348,6 +351,13 @@ - (void)mouseButtonState:(NSEvent *)event :(int)button :(int)state {
}

- (void)mouseDown:(NSEvent *)event {
if ([event modifierFlags] & NSControlKeyMask) {
rightMouseDown = true;
[self rightMouseDown:event];
return;
}

leftMouseDown = true;
[self mouseButtonState:event :0 :1];
}

Expand All @@ -360,7 +370,15 @@ - (void)otherMouseDown:(NSEvent *)event {
}

- (void)mouseUp:(NSEvent *)event {
[self mouseButtonState:event :0 :0];
if (rightMouseDown) {
rightMouseDown = false;
[self rightMouseUp:event];
}

if (leftMouseDown) {
leftMouseDown = false;
[self mouseButtonState:event :0 :0];
}
}

- (void)rightMouseUp:(NSEvent *)event {
Expand Down

0 comments on commit 43a6a8b

Please sign in to comment.