diff options
author | Cho <cho@lindenlab.com> | 2013-01-25 19:53:12 +0000 |
---|---|---|
committer | Cho <cho@lindenlab.com> | 2013-01-25 19:53:12 +0000 |
commit | 163f3de73d93be8f5e482be03a1952244cadee68 (patch) | |
tree | b57b2a7946f45e5365483d45d67649d44741b81b /indra/llui/lltexteditor.cpp | |
parent | d67804543d4042c1196c05db5303b76089d4ade2 (diff) |
CHUI-291 FIX New auto-replace feature does not work with chui text input boxes in conversation floater
Modified LLAutoReplace to pass back a string for replacement instead of modifying the input string
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r-- | indra/llui/lltexteditor.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 42c5f150dc..562bbc7100 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -1101,16 +1101,17 @@ void LLTextEditor::addChar(llwchar wc) if (!mReadOnly && mAutoreplaceCallback != NULL) { - // autoreplace on a copy of the text (so we can go through proper channels to set it later) - LLWString new_text(getWText()); - S32 new_cursor_pos(mCursorPos); - mAutoreplaceCallback(new_text, new_cursor_pos); - - if (new_text != getWText()) + // autoreplace the text, if necessary + S32 replacement_start; + S32 replacement_length; + LLWString replacement_string; + S32 new_cursor_pos = mCursorPos; + mAutoreplaceCallback(replacement_start, replacement_length, replacement_string, new_cursor_pos, getWText()); + + if (replacement_length > 0 || !replacement_string.empty()) { - // setText() might be simpler here but it wipes the undo stack (bad) - remove(0, getWText().length(), true); - insert(0, new_text, false, LLTextSegmentPtr()); + remove(replacement_start, replacement_length, true); + insert(replacement_start, replacement_string, false, LLTextSegmentPtr()); setCursorPos(new_cursor_pos); } } |