summaryrefslogtreecommitdiff
path: root/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorKitty Barnett <develop@catznip.com>2022-10-23 16:18:22 +0200
committerKitty Barnett <develop@catznip.com>2022-10-23 16:28:35 +0200
commit3acb4caa0fb9d381be6cfbe1693ace389d90a16c (patch)
treef81bb30bd36d01fe77e2f50e7f1621465510fe92 /indra/llui/lltexteditor.cpp
parentdad25bcb1e17e3dc384a9fb35d21b669bc3bbacd (diff)
Add emoji helper support to LLTextEditor
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r--indra/llui/lltexteditor.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 889940cf9a..168c260c7d 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -676,6 +676,21 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p
endSelection();
}
+void LLTextEditor::handleEmojiCommit(const LLWString& wstr)
+{
+ LLWString wtext(getWText()); S32 shortCodePos;
+ if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos))
+ {
+ remove(shortCodePos, mCursorPos - shortCodePos, true);
+
+ auto styleParams = LLStyle::Params();
+ styleParams.font = LLFontGL::getFontEmoji();
+ insert(shortCodePos, wstr, false, new LLEmojiTextSegment(new LLStyle(styleParams), shortCodePos, shortCodePos + wstr.size(), *this));
+
+ setCursorPos(shortCodePos + 1);
+ }
+}
+
BOOL LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
@@ -1147,9 +1162,9 @@ void LLTextEditor::addChar(llwchar wc)
LLWString wtext(getWText()); S32 shortCodePos;
if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos))
{
- const LLRect cursorRect = getLocalRectFromDocIndex(mCursorPos);
- const LLWString shortCode = wtext.substr(shortCodePos, mCursorPos);
- LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, wstring_to_utf8str(shortCode));
+ const LLRect cursorRect = getLocalRectFromDocIndex(mCursorPos - 1);
+ const LLWString shortCode = wtext.substr(shortCodePos, mCursorPos - shortCodePos);
+ LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, wstring_to_utf8str(shortCode), std::bind(&LLTextEditor::handleEmojiCommit, this, std::placeholders::_1));
}
}