Mac: Translate Ctrl-Left click to right click.
authorSam Lantinga <slouken@libsdl.org>
Fri, 13 Sep 2013 17:42:31 -0700
changeset 7740415bb39617a1
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
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Fri Sep 13 17:41:17 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Fri Sep 13 17:42:31 2013 -0700
     1.3 @@ -30,6 +30,7 @@
     1.4  @interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
     1.5      SDL_WindowData *_data;
     1.6      BOOL observingVisible;
     1.7 +    BOOL wasCtrlLeft;
     1.8      BOOL wasVisible;
     1.9  }
    1.10  
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 13 17:41:17 2013 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Sep 13 17:42:31 2013 -0700
     2.3 @@ -62,6 +62,7 @@
     2.4  
     2.5      _data = data;
     2.6      observingVisible = YES;
     2.7 +    wasCtrlLeft = NO;
     2.8      wasVisible = [window isVisible];
     2.9  
    2.10      center = [NSNotificationCenter defaultCenter];
    2.11 @@ -333,7 +334,13 @@
    2.12  
    2.13      switch ([theEvent buttonNumber]) {
    2.14      case 0:
    2.15 -        button = SDL_BUTTON_LEFT;
    2.16 +        if ([theEvent modifierFlags] & NSControlKeyMask) {
    2.17 +            wasCtrlLeft = YES;
    2.18 +            button = SDL_BUTTON_RIGHT;
    2.19 +        } else {
    2.20 +            wasCtrlLeft = NO;
    2.21 +            button = SDL_BUTTON_LEFT;
    2.22 +        }
    2.23          break;
    2.24      case 1:
    2.25          button = SDL_BUTTON_RIGHT;
    2.26 @@ -364,7 +371,12 @@
    2.27  
    2.28      switch ([theEvent buttonNumber]) {
    2.29      case 0:
    2.30 -        button = SDL_BUTTON_LEFT;
    2.31 +        if (wasCtrlLeft) {
    2.32 +            button = SDL_BUTTON_RIGHT;
    2.33 +            wasCtrlLeft = NO;
    2.34 +        } else {
    2.35 +            button = SDL_BUTTON_LEFT;
    2.36 +        }
    2.37          break;
    2.38      case 1:
    2.39          button = SDL_BUTTON_RIGHT;