summaryrefslogtreecommitdiff
path: root/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorCho <cho@lindenlab.com>2013-01-25 01:57:56 +0000
committerCho <cho@lindenlab.com>2013-01-25 01:57:56 +0000
commitd67804543d4042c1196c05db5303b76089d4ade2 (patch)
treef585cc4180185af1acc7866582152b54b3e348db /indra/llui/lltexteditor.cpp
parent9312cd8709132835878bdbe17f81d1b3e9fa7f45 (diff)
CHUI-291 FIX New auto-replace feature does not work with chui text input boxes in conversation floater
Fixed autoreplace in LLTextEditor so it updates correctly and works with undo
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r--indra/llui/lltexteditor.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index d297e54f2f..42c5f150dc 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -246,8 +246,8 @@ LLTextEditor::Params::Params()
}
LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
- LLTextBase(p),
- mAutoreplaceCallback(),
+ LLTextBase(p),
+ mAutoreplaceCallback(),
mBaseDocIsPristine(TRUE),
mPristineCmd( NULL ),
mLastCmd( NULL ),
@@ -1099,11 +1099,21 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
- if (!mReadOnly && mAutoreplaceCallback != NULL)
- {
- // call callback
- mAutoreplaceCallback(getViewModel()->getEditableDisplay(), mCursorPos);
- }
+ 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())
+ {
+ // setText() might be simpler here but it wipes the undo stack (bad)
+ remove(0, getWText().length(), true);
+ insert(0, new_text, false, LLTextSegmentPtr());
+ setCursorPos(new_cursor_pos);
+ }
+ }
}
void LLTextEditor::addLineBreakChar()