summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sdl2-macos-ios.diff18
-rw-r--r--src/macos.m5
2 files changed, 16 insertions, 7 deletions
diff --git a/sdl2-macos-ios.diff b/sdl2-macos-ios.diff
index ecb23824..62178f63 100644
--- a/sdl2-macos-ios.diff
+++ b/sdl2-macos-ios.diff
@@ -37,31 +37,39 @@ index e9d832d64..4cfa3624b 100644
37 if ([event isDirectionInvertedFromDevice] == YES) { 37 if ([event isDirectionInvertedFromDevice] == YES) {
38 direction = SDL_MOUSEWHEEL_FLIPPED; 38 direction = SDL_MOUSEWHEEL_FLIPPED;
39diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h 39diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
40index 37bec665e..5e3a3995f 100644 40index 37bec665e..9b2f0510c 100644
41--- a/src/video/cocoa/SDL_cocoawindow.h 41--- a/src/video/cocoa/SDL_cocoawindow.h
42+++ b/src/video/cocoa/SDL_cocoawindow.h 42+++ b/src/video/cocoa/SDL_cocoawindow.h
43@@ -109,6 +109,8 @@ typedef enum 43@@ -109,6 +109,8 @@ typedef enum
44 /* Touch event handling */ 44 /* Touch event handling */
45 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent; 45 -(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
46 46
47+-(void) syncMouseButtonState; 47+-(void) syncMouseButtonAndKeyboardModifierState;
48+ 48+
49 @end 49 @end
50 /* *INDENT-ON* */ 50 /* *INDENT-ON* */
51 51
52diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m 52diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
53index 7a1446f09..86db35600 100644 53index 7a1446f09..a6da2f9d7 100644
54--- a/src/video/cocoa/SDL_cocoawindow.m 54--- a/src/video/cocoa/SDL_cocoawindow.m
55+++ b/src/video/cocoa/SDL_cocoawindow.m 55+++ b/src/video/cocoa/SDL_cocoawindow.m
56@@ -1073,6 +1073,13 @@ - (void)otherMouseDown:(NSEvent *)theEvent 56@@ -1073,6 +1073,21 @@ - (void)otherMouseDown:(NSEvent *)theEvent
57 [self mouseDown:theEvent]; 57 [self mouseDown:theEvent];
58 } 58 }
59 59
60+- (void)syncMouseButtonState { 60+- (void)syncMouseButtonAndKeyboardModifierState {
61+ SDL_Mouse *mouse = SDL_GetMouse(); 61+ SDL_Mouse *mouse = SDL_GetMouse();
62+ if (mouse) { 62+ if (mouse) {
63+ mouse->buttonstate = SDL_GetGlobalMouseState(NULL, NULL); 63+ mouse->buttonstate = SDL_GetGlobalMouseState(NULL, NULL);
64+ } 64+ }
65+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
66+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
67+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
68+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
69+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
70+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
71+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
72+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
65+} 73+}
66+ 74+
67 - (void)mouseUp:(NSEvent *)theEvent 75 - (void)mouseUp:(NSEvent *)theEvent
diff --git a/src/macos.m b/src/macos.m
index 53a6da00..78b964ae 100644
--- a/src/macos.m
+++ b/src/macos.m
@@ -673,8 +673,9 @@ void showPopupMenu_MacOS(iWidget *source, iInt2 windowCoord, const iMenuItem *it
673 [menu release]; 673 [menu release];
674 [menuCommands release]; 674 [menuCommands release];
675 /* The right mouse button has now been released so let SDL know about it. The button up event 675 /* The right mouse button has now been released so let SDL know about it. The button up event
676 was consumed by the popup menu so it got never passed to SDL. */ 676 was consumed by the popup menu so it got never passed to SDL. Same goes for possible
677 SEL sel = NSSelectorFromString(@"syncMouseButtonState"); /* custom method */ 677 keyboard modifiers that were held down when the menu appeared. */
678 SEL sel = NSSelectorFromString(@"syncMouseButtonAndKeyboardModifierState"); /* custom method */
678 if ([[nsWindow delegate] respondsToSelector:sel]) { 679 if ([[nsWindow delegate] respondsToSelector:sel]) {
679 NSInvocation *call = [NSInvocation invocationWithMethodSignature: 680 NSInvocation *call = [NSInvocation invocationWithMethodSignature:
680 [NSMethodSignature signatureWithObjCTypes:"v@:"]]; 681 [NSMethodSignature signatureWithObjCTypes:"v@:"]];