This seems to be on par with viewer-release at this point.
parent
84f287b34e
commit
2837ca7a47
|
|
@ -22,7 +22,6 @@
|
|||
float mMousePos[2];
|
||||
bool mHasMarkedText;
|
||||
unsigned int mMarkedTextLength;
|
||||
NSAttributedString *mMarkedText;
|
||||
bool mMarkedTextAllowed;
|
||||
}
|
||||
- (id) initWithSamples:(NSUInteger)samples;
|
||||
|
|
|
|||
|
|
@ -314,37 +314,34 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
|
||||
- (void) keyDown:(NSEvent *)theEvent
|
||||
{
|
||||
if (!mHasMarkedText)
|
||||
{
|
||||
uint keycode = [theEvent keyCode];
|
||||
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
|
||||
{
|
||||
[[self inputContext] handleEvent:theEvent];
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
// OS X intentionally does not send us key-up information on cmd-key combinations.
|
||||
// This behaviour is not a bug, and only applies to cmd-combinations (no others).
|
||||
// Since SL assumes we receive those, we fake it here.
|
||||
if (mModifiers & NSCommandKeyMask)
|
||||
{
|
||||
callKeyUp([theEvent keyCode], mModifiers);
|
||||
}
|
||||
}
|
||||
uint keycode = [theEvent keyCode];
|
||||
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
|
||||
{
|
||||
[[self inputContext] handleEvent:theEvent];
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
// OS X intentionally does not send us key-up information on cmd-key combinations.
|
||||
// This behaviour is not a bug, and only applies to cmd-combinations (no others).
|
||||
// Since SL assumes we receive those, we fake it here.
|
||||
if (mModifiers & NSCommandKeyMask)
|
||||
{
|
||||
callKeyUp([theEvent keyCode], mModifiers);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)theEvent {
|
||||
|
|
@ -425,7 +422,6 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
{
|
||||
if (mMarkedTextAllowed)
|
||||
{
|
||||
|
||||
unsigned int selected[2] = {
|
||||
selectedRange.location,
|
||||
selectedRange.length
|
||||
|
|
@ -442,9 +438,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
setMarkedText(text, selected, replacement, [aString length], segments);
|
||||
mHasMarkedText = TRUE;
|
||||
mMarkedTextLength = [aString length];
|
||||
mMarkedText = (NSAttributedString*)[aString mutableString];
|
||||
} else {
|
||||
if (mHasMarkedText || ![mMarkedText isEqual: @""])
|
||||
if (mHasMarkedText)
|
||||
{
|
||||
[self unmarkText];
|
||||
}
|
||||
|
|
@ -454,17 +449,18 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
|
||||
- (void)commitCurrentPreedit
|
||||
{
|
||||
if (mMarkedText)
|
||||
if (mHasMarkedText)
|
||||
{
|
||||
[self insertText:mMarkedText];
|
||||
[[self inputContext] discardMarkedText];
|
||||
if ([[self inputContext] respondsToSelector:@selector(commitEditing)])
|
||||
{
|
||||
[[self inputContext] commitEditing];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unmarkText
|
||||
{
|
||||
[[self inputContext] discardMarkedText];
|
||||
[mMarkedText setValue:@""];
|
||||
resetPreedit();
|
||||
mHasMarkedText = FALSE;
|
||||
}
|
||||
|
|
@ -481,6 +477,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void)insertText:(id)insertString
|
||||
{
|
||||
if (insertString != nil)
|
||||
{
|
||||
[self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
if (!mHasMarkedText)
|
||||
|
|
@ -490,9 +494,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
callUnicodeCallback([aString characterAtIndex:i], mModifiers);
|
||||
}
|
||||
} else {
|
||||
resetPreedit();
|
||||
// We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.
|
||||
// But just in case...
|
||||
resetPreedit();
|
||||
|
||||
for (NSInteger i = 0; i < [aString length]; i++)
|
||||
{
|
||||
|
|
@ -567,7 +571,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
|
|||
[[self inputContext] discardMarkedText];
|
||||
[self setString:@""];
|
||||
[_window orderOut:_window];
|
||||
[self insertText:insertString replacementRange:NSMakeRange(0, 0)];
|
||||
[self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])];
|
||||
}
|
||||
|
||||
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void resetPreedit();
|
|||
int wstring_length(const std::basic_string<wchar_t> & wstr, const int woffset, const int utf16_length, int *unaligned);
|
||||
void setMarkedText(unsigned short *text, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, attributedStringInfo segments);
|
||||
void getPreeditLocation(float *location, unsigned int length);
|
||||
void allowDirectMarkedTextInput(bool allow);
|
||||
void allowDirectMarkedTextInput(bool allow, GLViewRef glView);
|
||||
|
||||
NSWindowRef getMainAppWindow();
|
||||
GLViewRef getGLView();
|
||||
|
|
|
|||
|
|
@ -372,9 +372,9 @@ void commitCurrentPreedit(GLViewRef glView)
|
|||
[(LLOpenGLView*)glView commitCurrentPreedit];
|
||||
}
|
||||
|
||||
void allowDirectMarkedTextInput(bool allow)
|
||||
void allowDirectMarkedTextInput(bool allow, GLViewRef glView)
|
||||
{
|
||||
|
||||
[(LLOpenGLView*)glView allowMarkedTextInput:allow];
|
||||
}
|
||||
|
||||
NSWindowRef getMainAppWindow()
|
||||
|
|
|
|||
|
|
@ -239,6 +239,11 @@ void callFocusLost()
|
|||
|
||||
void callRightMouseDown(float *pos, MASK mask)
|
||||
{
|
||||
if (gWindowImplementation->allowsLanguageInput())
|
||||
{
|
||||
gWindowImplementation->interruptLanguageTextInput();
|
||||
}
|
||||
|
||||
LLCoordGL outCoords;
|
||||
outCoords.mX = llround(pos[0]);
|
||||
outCoords.mY = llround(pos[1]);
|
||||
|
|
@ -247,6 +252,11 @@ void callRightMouseDown(float *pos, MASK mask)
|
|||
|
||||
void callRightMouseUp(float *pos, MASK mask)
|
||||
{
|
||||
if (gWindowImplementation->allowsLanguageInput())
|
||||
{
|
||||
gWindowImplementation->interruptLanguageTextInput();
|
||||
}
|
||||
|
||||
LLCoordGL outCoords;
|
||||
outCoords.mX = llround(pos[0]);
|
||||
outCoords.mY = llround(pos[1]);
|
||||
|
|
@ -255,6 +265,11 @@ void callRightMouseUp(float *pos, MASK mask)
|
|||
|
||||
void callLeftMouseDown(float *pos, MASK mask)
|
||||
{
|
||||
if (gWindowImplementation->allowsLanguageInput())
|
||||
{
|
||||
gWindowImplementation->interruptLanguageTextInput();
|
||||
}
|
||||
|
||||
LLCoordGL outCoords;
|
||||
outCoords.mX = llround(pos[0]);
|
||||
outCoords.mY = llround(pos[1]);
|
||||
|
|
@ -263,6 +278,11 @@ void callLeftMouseDown(float *pos, MASK mask)
|
|||
|
||||
void callLeftMouseUp(float *pos, MASK mask)
|
||||
{
|
||||
if (gWindowImplementation->allowsLanguageInput())
|
||||
{
|
||||
gWindowImplementation->interruptLanguageTextInput();
|
||||
}
|
||||
|
||||
LLCoordGL outCoords;
|
||||
outCoords.mX = llround(pos[0]);
|
||||
outCoords.mY = llround(pos[1]);
|
||||
|
|
@ -272,6 +292,11 @@ void callLeftMouseUp(float *pos, MASK mask)
|
|||
|
||||
void callDoubleClick(float *pos, MASK mask)
|
||||
{
|
||||
if (gWindowImplementation->allowsLanguageInput())
|
||||
{
|
||||
gWindowImplementation->interruptLanguageTextInput();
|
||||
}
|
||||
|
||||
LLCoordGL outCoords;
|
||||
outCoords.mX = llround(pos[0]);
|
||||
outCoords.mY = llround(pos[1]);
|
||||
|
|
@ -434,7 +459,7 @@ void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigne
|
|||
if (gWindowImplementation->getPreeditor())
|
||||
{
|
||||
LLPreeditor *preeditor = gWindowImplementation->getPreeditor();
|
||||
|
||||
preeditor->resetPreedit();
|
||||
// This should be a viable replacement for the kEventParamTextInputSendReplaceRange parameter.
|
||||
if (replacementRange[0] < replacementRange[1])
|
||||
{
|
||||
|
|
@ -444,8 +469,6 @@ void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigne
|
|||
preeditor->markAsPreedit(location, length);
|
||||
}
|
||||
|
||||
preeditor->resetPreedit();
|
||||
|
||||
LLWString fix_str = utf16str_to_wstring(llutf16string(unitext, text_len));
|
||||
|
||||
S32 caret_position = fix_str.length();
|
||||
|
|
@ -1818,6 +1841,8 @@ static long getDictLong (CFDictionaryRef refDict, CFStringRef key)
|
|||
|
||||
void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
|
||||
{
|
||||
allowDirectMarkedTextInput(b, mGLView);
|
||||
|
||||
if (preeditor != mPreeditor && !b)
|
||||
{
|
||||
// This condition may occur by a call to
|
||||
|
|
@ -1828,16 +1853,7 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
|
|||
// is not disturbed.
|
||||
return;
|
||||
}
|
||||
|
||||
if (preeditor == NULL) {
|
||||
// If we don't have a pre editor, then we can't accept direct marked text input.
|
||||
// We needs an input window (which is handled internally by LLOpenGLView)
|
||||
allowDirectMarkedTextInput(false);
|
||||
} else {
|
||||
// If we have a preeditor, then accept direct marked text input.
|
||||
allowDirectMarkedTextInput(true);
|
||||
}
|
||||
|
||||
|
||||
// Take care of old and new preeditors.
|
||||
if (preeditor != mPreeditor || !b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ public:
|
|||
void getMouseDeltas(float* delta);
|
||||
|
||||
void handleDragNDrop(std::string url, LLWindowCallbacks::DragNDropAction action);
|
||||
|
||||
bool allowsLanguageInput() { return mLanguageTextInputAllowed; }
|
||||
|
||||
protected:
|
||||
LLWindowMacOSX(LLWindowCallbacks* callbacks,
|
||||
|
|
|
|||
Loading…
Reference in New Issue