Mac: Translate Ctrl-Left click to right click.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
index 022694f..c08c55c 100644
--- a/src/video/cocoa/SDL_cocoawindow.h
+++ b/src/video/cocoa/SDL_cocoawindow.h
@@ -30,6 +30,7 @@ typedef struct SDL_WindowData SDL_WindowData;
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
SDL_WindowData *_data;
BOOL observingVisible;
+ BOOL wasCtrlLeft;
BOOL wasVisible;
}
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index cd4771d..ecfab82 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -62,6 +62,7 @@ static void ScheduleContextUpdates(SDL_WindowData *data)
_data = data;
observingVisible = YES;
+ wasCtrlLeft = NO;
wasVisible = [window isVisible];
center = [NSNotificationCenter defaultCenter];
@@ -333,7 +334,13 @@ static void ScheduleContextUpdates(SDL_WindowData *data)
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;
@@ -364,7 +371,12 @@ static void ScheduleContextUpdates(SDL_WindowData *data)
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;