Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mac: Translate Ctrl-Left click to right click.
  • Loading branch information
slouken committed Sep 14, 2013
1 parent e231d5b commit 67c02a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/video/cocoa/SDL_cocoawindow.h
Expand Up @@ -30,6 +30,7 @@ typedef struct SDL_WindowData SDL_WindowData;
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
SDL_WindowData *_data;
BOOL observingVisible;
BOOL wasCtrlLeft;
BOOL wasVisible;
}

Expand Down
16 changes: 14 additions & 2 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -62,6 +62,7 @@ - (void)listen:(SDL_WindowData *)data

_data = data;
observingVisible = YES;
wasCtrlLeft = NO;
wasVisible = [window isVisible];

center = [NSNotificationCenter defaultCenter];
Expand Down Expand Up @@ -333,7 +334,13 @@ - (void)mouseDown:(NSEvent *)theEvent

switch ([theEvent buttonNumber]) {
case 0:
button = SDL_BUTTON_LEFT;
if ([theEvent modifierFlags] & NSControlKeyMask) {
wasCtrlLeft = YES;
button = SDL_BUTTON_RIGHT;
} else {
wasCtrlLeft = NO;
button = SDL_BUTTON_LEFT;
}
break;
case 1:
button = SDL_BUTTON_RIGHT;
Expand Down Expand Up @@ -364,7 +371,12 @@ - (void)mouseUp:(NSEvent *)theEvent

switch ([theEvent buttonNumber]) {
case 0:
button = SDL_BUTTON_LEFT;
if (wasCtrlLeft) {
button = SDL_BUTTON_RIGHT;
wasCtrlLeft = NO;
} else {
button = SDL_BUTTON_LEFT;
}
break;
case 1:
button = SDL_BUTTON_RIGHT;
Expand Down

0 comments on commit 67c02a2

Please sign in to comment.