Added SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK hint which controls whether ctrl+click should emulate a right click on OSX.
authorSam Lantinga <slouken@libsdl.org>
Fri, 08 Nov 2013 14:04:51 -0800
changeset 7915 86ad156a82ab
parent 7914 a391318fa60f
child 7916 8f16728ce87b
Added SDL_HINT_CTRL_CLICK_EMULATE_RIGHT_CLICK hint which controls whether ctrl+click should emulate a right click on OSX.
include/SDL_hints.h
src/video/cocoa/SDL_cocoawindow.m
--- a/include/SDL_hints.h	Fri Nov 08 14:04:35 2013 -0800
+++ b/include/SDL_hints.h	Fri Nov 08 14:04:51 2013 -0800
@@ -283,6 +283,14 @@
  */
 #define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED"
 
+/**
+ *  \brief A variable that determines whether ctrl+click should generate a right-click event on Mac
+ *  
+ *  If present, holding ctrl while left clicking will generate a right click
+ *  event when on Mac.
+ */
+#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK"
+
 
 /**
  *  \brief  An enumeration of hint priorities
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Nov 08 14:04:35 2013 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Nov 08 14:04:51 2013 -0800
@@ -24,6 +24,7 @@
 
 #include "SDL_syswm.h"
 #include "SDL_timer.h"  /* For SDL_GetTicks() */
+#include "SDL_hints.h"
 #include "../SDL_sysvideo.h"
 #include "../../events/SDL_keyboard_c.h"
 #include "../../events/SDL_mouse_c.h"
@@ -59,6 +60,12 @@
     }
 }
 
+static int GetHintCtrlClickEmulateRightClick()
+{
+	const char *hint = SDL_GetHint( SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK );
+	return hint != NULL && *hint != '0';
+}
+
 @implementation Cocoa_WindowListener
 
 - (void)listen:(SDL_WindowData *)data
@@ -341,7 +348,8 @@
 
     switch ([theEvent buttonNumber]) {
     case 0:
-        if ([theEvent modifierFlags] & NSControlKeyMask) {
+        if (([theEvent modifierFlags] & NSControlKeyMask) &&
+		    GetHintCtrlClickEmulateRightClick()) {
             wasCtrlLeft = YES;
             button = SDL_BUTTON_RIGHT;
         } else {