Mac: Translate Ctrl-Left click to right click.
authorSam Lantinga <slouken@libsdl.org>
Fri, 13 Sep 2013 17:42:31 -0700
changeset 7740 415bb39617a1
parent 7739 329c9da4bfeb
child 7741 199d77d7bf1c
Mac: Translate Ctrl-Left click to right click.
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.h	Fri Sep 13 17:41:17 2013 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.h	Fri Sep 13 17:42:31 2013 -0700
@@ -30,6 +30,7 @@
 @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
     SDL_WindowData *_data;
     BOOL observingVisible;
+    BOOL wasCtrlLeft;
     BOOL wasVisible;
 }
 
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 13 17:41:17 2013 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 13 17:42:31 2013 -0700
@@ -62,6 +62,7 @@
 
     _data = data;
     observingVisible = YES;
+    wasCtrlLeft = NO;
     wasVisible = [window isVisible];
 
     center = [NSNotificationCenter defaultCenter];
@@ -333,7 +334,13 @@
 
     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 @@
 
     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;