diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 3e2b42f9e0..7955669d0f 100755 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -157,7 +157,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mHighlightColor(p.highlight_color()), mPreeditBgColor(p.preedit_bg_color()), mGLFont(p.font), - mContextMenuHandle() + mContextMenuHandle(), + mAutoreplaceCallback() { llassert( mMaxLengthBytes > 0 ); @@ -980,6 +981,25 @@ void LLLineEditor::addChar(const llwchar uni_char) LLUI::reportBadKeystroke(); } + // FIRE-11373: Autoreplace doesn't work in nearby chat bar + if (!mReadOnly && mAutoreplaceCallback != NULL) + { + // autoreplace the text, if necessary + S32 replacement_start; + S32 replacement_length; + LLWString replacement_string; + S32 new_cursor_pos = getCursor(); + mAutoreplaceCallback(replacement_start, replacement_length, replacement_string, new_cursor_pos, getWText()); + + if (replacement_length > 0 || !replacement_string.empty()) + { + mText.erase(replacement_start, replacement_length); + mText.insert(replacement_start, replacement_string); + setCursor(new_cursor_pos); + } + } + // FIRE-11373 + getWindow()->hideCursorUntilMouseMove(); } diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index fcffe67d25..1ab5d25346 100755 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -189,6 +189,12 @@ public: virtual BOOL setTextArg( const std::string& key, const LLStringExplicit& text ); virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text ); + // FIRE-11373: Autoreplace doesn't work in nearby chat bar + typedef boost::function autoreplace_callback_t; + autoreplace_callback_t mAutoreplaceCallback; + void setAutoreplaceCallback (autoreplace_callback_t cb) { mAutoreplaceCallback = cb; } + // FIRE-11373 + void setLabel(const LLStringExplicit &new_label) { mLabel = new_label; } const std::string& getLabel() { return mLabel.getString(); } diff --git a/indra/newview/fsnearbychatcontrol.cpp b/indra/newview/fsnearbychatcontrol.cpp index a379c72d18..6b4b686d37 100644 --- a/indra/newview/fsnearbychatcontrol.cpp +++ b/indra/newview/fsnearbychatcontrol.cpp @@ -109,9 +109,8 @@ static LLChatTypeTrigger sChatTypeTriggers[] = { FSNearbyChatControl::FSNearbyChatControl(const FSNearbyChatControl::Params& p) : LLLineEditor(p) { - /// FIXME: Commenting out for now, will either rehook up autoreplace to LLLineEditor or - /// move to CHUI style expanding text editors - //setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2)); + // FIRE-11373: Autoreplace doesn't work in nearby chat bar + setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2, _3, _4, _5)); setKeystrokeCallback(onKeystroke,this); FSNearbyChat::instance().registerChatBar(this);