From 2760d30363716b8d469134d197a9874eccea6aa3 Mon Sep 17 00:00:00 2001 From: thickbrick Date: Sat, 25 Sep 2010 16:14:11 +0200 Subject: LLTextEditor context translator: set selection after translation. --- linden/indra/llui/lltexteditor.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'linden/indra/llui') diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index adf0260..d59eed6 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -499,8 +499,9 @@ void LLTextEditor::translateText(void * data) if (has_text) { + const std::string to_translate = wstring_to_utf8str(line->getWText().substr(start, length)); LLHTTPClient::ResponderPtr result = TextChatTranslationReceiver::build(toLang, line, start, length); - LLTranslate::translateMessage(result,"", toLang, line->getText().substr(start, length)); + LLTranslate::translateMessage(result,"", toLang, to_translate); } } @@ -2290,8 +2291,13 @@ void LLTextEditor::translationReplace(const std::string &translation, const S32 { remove(orig_start, orig_length, FALSE); } - insert(pos, wtext, FALSE); - setCursorPos(pos + wtext.length()); + S32 inserted = insert(pos, wtext, FALSE); + if (hasSelection()) + { + mSelectionStart = llclamp(pos, 0, getLength()); + mSelectionEnd = llclamp(pos + inserted, mSelectionStart, getLength()); + } + setCursorPos(pos + inserted); needsReflow(); } -- cgit v1.1