diff options
author | Geenz <geenz@geenzo.com> | 2013-06-17 12:31:25 -0400 |
---|---|---|
committer | Geenz <geenz@geenzo.com> | 2013-06-17 12:31:25 -0400 |
commit | 84f287b34e7d7edbd2e897b73008c782aabe60de (patch) | |
tree | 95776c0be794527e0650c49b52146333a183ace7 | |
parent | 2253d22eb85a6b4c5e48b9905d807d0ac48b1930 (diff) |
Moved detecting if we're using a roman-script language to it's own function in the application delegate. Also consider the delete and backspace characters to be special cases.
-rw-r--r-- | indra/llwindow/llappdelegate-objc.h | 1 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 22 | ||||
-rw-r--r-- | indra/newview/llappdelegate-objc.mm | 22 |
3 files changed, 31 insertions, 14 deletions
diff --git a/indra/llwindow/llappdelegate-objc.h b/indra/llwindow/llappdelegate-objc.h index 266f417c4b..a6fb77d93f 100644 --- a/indra/llwindow/llappdelegate-objc.h +++ b/indra/llwindow/llappdelegate-objc.h @@ -26,4 +26,5 @@ - (void) mainLoop; - (void) showInputWindow:(bool)show withEvent:(NSEvent*)textEvent; - (void) languageUpdated; +- (bool) romanScript; @end diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 2afd4993c5..c3f0ef4aeb 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -317,15 +317,21 @@ attributedStringInfo getSegments(NSAttributedString *str) if (!mHasMarkedText) { uint keycode = [theEvent keyCode]; - if (callKeyDown(keycode, mModifiers)) + bool acceptsText = callKeyDown(keycode, mModifiers); + if (acceptsText && + !mMarkedTextAllowed && + ![(LLAppDelegate*)[NSApp delegate] romanScript] && + [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSDeleteCharacter && + [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSBackspaceCharacter) + { + [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent]; + } else { - if (!mMarkedTextAllowed && [[theEvent characters] characterAtIndex:0] != NSBackspaceCharacter) - { - [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent]; - } - [[self inputContext] handleEvent:theEvent]; - } else if ([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == 13 || [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == 3) + } + + if ([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSCarriageReturnCharacter || + [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == NSEnterCharacter) { // callKeyDown won't return the value we expect for enter or return. Handle them as a separate case. [[self inputContext] handleEvent:theEvent]; @@ -438,7 +444,7 @@ attributedStringInfo getSegments(NSAttributedString *str) mMarkedTextLength = [aString length]; mMarkedText = (NSAttributedString*)[aString mutableString]; } else { - if (mHasMarkedText) + if (mHasMarkedText || ![mMarkedText isEqual: @""]) { [self unmarkText]; } diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index cec9c586e6..6b7e613491 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -73,11 +73,7 @@ - (void) showInputWindow:(bool)show withEvent:(NSEvent*)textEvent { - // How to add support for new languages with the input window: - // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) - NSArray *authorizedLanguages = [[NSArray alloc] initWithObjects:@"ja", @"ko", @"zh-Hant", @"zh-Hans", nil]; - - if ([authorizedLanguages containsObject:currentInputLanguage]) + if (![self romanScript]) { if (show) { @@ -85,6 +81,7 @@ [inputWindow makeKeyAndOrderFront:inputWindow]; if (textEvent != nil) { + [[inputView inputContext] discardMarkedText]; [[inputView inputContext] handleEvent:textEvent]; } } else { @@ -105,7 +102,7 @@ TISInputSourceRef currentInput = TISCopyCurrentKeyboardInputSource(); CFArrayRef languages = (CFArrayRef)TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages); -#if 1 // In the event of ever needing to add new language sources, change this to 1 and watch the terminal for "languages:" +#if 0 // In the event of ever needing to add new language sources, change this to 1 and watch the terminal for "languages:" NSLog(@"languages: %@", TISGetInputSourceProperty(currentInput, kTISPropertyInputSourceLanguages)); #endif @@ -113,4 +110,17 @@ currentInputLanguage = (NSString*)CFArrayGetValueAtIndex(languages, 0); } +- (bool) romanScript +{ + // How to add support for new languages with the input window: + // Simply append this array with the language code (ja for japanese, ko for korean, zh for chinese, etc.) + NSArray *nonRomanScript = [[NSArray alloc] initWithObjects:@"ja", @"ko", @"zh-Hant", @"zh-Hans", nil]; + if ([nonRomanScript containsObject:currentInputLanguage]) + { + return false; + } + + return true; +} + @end |