From fd55bc6dededbeac7c0bb6acba54e16f0a2f382b Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 7 Apr 2014 18:00:36 +0200 Subject: [PATCH] Make sure to grab current modifiers on keypress/mouse so they don't get stuck until pressed again. --- indra/llwindow/llopenglview-objc.mm | 16 ++++++++++++++++ indra/llwindow/llwindowmacosx-objc.mm | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 129c65829e..85f34af047 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -248,6 +248,8 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) mouseDown:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + // Apparently people still use this? if ([theEvent modifierFlags] & NSCommandKeyMask && !([theEvent modifierFlags] & (NSControlKeyMask | NSShiftKeyMask @@ -270,6 +272,8 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) mouseUp:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + if (mSimulatedRightClick) { callRightMouseUp(mMousePos, mModifiers); @@ -281,11 +285,15 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) rightMouseDown:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + callRightMouseDown(mMousePos, mModifiers); } - (void) rightMouseUp:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + callRightMouseUp(mMousePos, mModifiers); } @@ -327,11 +335,15 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) otherMouseDown:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + callMiddleMouseDown(mMousePos, mModifiers); } - (void) otherMouseUp:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + callMiddleMouseUp(mMousePos, mModifiers); } @@ -352,11 +364,15 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) keyUp:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + callKeyUp([theEvent keyCode], mModifiers); } - (void) keyDown:(NSEvent *)theEvent { + mModifiers = [theEvent modifierFlags]; // Make sure we're grabbing current modifiers, or they might get stuck until another one is pressed. + uint keycode = [theEvent keyCode]; bool acceptsText = mHasMarkedText ? false : callKeyDown(keycode, mModifiers); if (acceptsText && diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 9a5f8a46b3..8b149920d6 100755 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -454,6 +454,14 @@ long showAlert(std::string text, std::string title, int type) unsigned int getModifiers() { + // Try current event of app first, otherwise we might get wrong results + NSEvent *pEvent = [NSApp currentEvent]; + if( pEvent != nil ) + { + return [pEvent modifierFlags]; + } + // + return [NSEvent modifierFlags]; }