summaryrefslogtreecommitdiff
path: root/indra/llwindow/llopenglview-objc.mm
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2015-12-18 10:44:42 -0500
committerOz Linden <oz@lindenlab.com>2015-12-18 10:44:42 -0500
commit4b7ff25eba4b285e267ec6f766221ffcde82a808 (patch)
treee8a885c7167046bec9311981a7f690a190248b2a /indra/llwindow/llopenglview-objc.mm
parentd3b4f34eb7ff80315f1d714aa50bc7d7d33f9855 (diff)
parent7b993d15b70d419dc0a7c8d92286d34a2635537d (diff)
merge changes for 4.0.0-release
Diffstat (limited to 'indra/llwindow/llopenglview-objc.mm')
-rw-r--r--indra/llwindow/llopenglview-objc.mm47
1 files changed, 42 insertions, 5 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index deb8cb90d8..406bc9cf47 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -28,6 +28,11 @@
#include "llwindowmacosx-objc.h"
#import "llappdelegate-objc.h"
+
+
+
+//---------------------------
+
@implementation NSScreen (PointConversion)
+ (NSScreen *)currentScreenForMouseLocation
@@ -42,6 +47,7 @@
return screen;
}
+
- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint
{
float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x));
@@ -57,6 +63,21 @@
@end
+void extractKeyDataFromEvent (NSEvent *theEvent, NativeKeyEventData * eventData)
+{
+ eventData->mKeyEvent = NativeKeyEventData::KEYUNKNOWN;
+ eventData->mEventType = [theEvent type];
+ eventData->mEventModifiers = [theEvent modifierFlags];
+ eventData->mEventKeyCode = [theEvent keyCode];
+ NSString *strEventChars = [theEvent characters];
+ eventData->mEventChars = (strEventChars.length) ? [strEventChars characterAtIndex:0] : 0;
+ NSString *strEventUChars = [theEvent charactersIgnoringModifiers];
+ eventData->mEventUnmodChars = (strEventUChars.length) ? [strEventUChars characterAtIndex:0] : 0;
+ eventData->mEventRepeat = [theEvent isARepeat];
+
+}
+
+
attributedStringInfo getSegments(NSAttributedString *str)
{
attributedStringInfo segments;
@@ -402,11 +423,20 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) keyUp:(NSEvent *)theEvent
{
- callKeyUp([theEvent keyCode], [theEvent modifierFlags]);
+ NativeKeyEventData eventData;
+
+ extractKeyDataFromEvent( theEvent, &eventData );
+ eventData.mKeyEvent = NativeKeyEventData::KEYUP;
+ callKeyUp(&eventData, [theEvent keyCode], [theEvent modifierFlags]);
}
- (void) keyDown:(NSEvent *)theEvent
{
+ NativeKeyEventData eventData;
+
+ extractKeyDataFromEvent( theEvent, &eventData );
+ eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
+
uint keycode = [theEvent keyCode];
// We must not depend on flagsChange event to detect modifier flags changed,
// must depend on the modifire flags in the event parameter.
@@ -414,7 +444,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
// e.g. OS Window for upload something or Input Window...
// mModifiers instance variable is for insertText: or insertText:replacementRange: (by Pell Smit)
mModifiers = [theEvent modifierFlags];
- bool acceptsText = mHasMarkedText ? false : callKeyDown(keycode, mModifiers);
+ bool acceptsText = mHasMarkedText ? false : callKeyDown(&eventData, keycode, mModifiers);
unichar ch;
if (acceptsText &&
!mMarkedTextAllowed &&
@@ -435,12 +465,17 @@ attributedStringInfo getSegments(NSAttributedString *str)
// Since SL assumes we receive those, we fake it here.
if (mModifiers & NSCommandKeyMask && !mHasMarkedText)
{
- callKeyUp([theEvent keyCode], mModifiers);
+ eventData.mKeyEvent = NativeKeyEventData::KEYUP;
+ callKeyUp(&eventData, [theEvent keyCode], mModifiers);
}
}
- (void)flagsChanged:(NSEvent *)theEvent
{
+ NativeKeyEventData eventData;
+
+ extractKeyDataFromEvent( theEvent, &eventData );
+
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);
@@ -462,11 +497,13 @@ attributedStringInfo getSegments(NSAttributedString *str)
if (mModifiers & mask)
{
- callKeyDown([theEvent keyCode], 0);
+ eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
+ callKeyDown(&eventData, [theEvent keyCode], 0);
}
else
{
- callKeyUp([theEvent keyCode], 0);
+ eventData.mKeyEvent = NativeKeyEventData::KEYUP;
+ callKeyUp(&eventData, [theEvent keyCode], 0);
}
}