Skip to content
Snippets Groups Projects
Commit 3acb4caa authored by Kitty Barnett's avatar Kitty Barnett
Browse files

Add emoji helper support to LLTextEditor

parent dad25bcb
No related branches found
No related tags found
No related merge requests found
...@@ -676,6 +676,21 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p ...@@ -676,6 +676,21 @@ void LLTextEditor::selectByCursorPosition(S32 prev_cursor_pos, S32 next_cursor_p
endSelection(); 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 LLTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
{ {
BOOL handled = FALSE; BOOL handled = FALSE;
...@@ -1147,9 +1162,9 @@ void LLTextEditor::addChar(llwchar wc) ...@@ -1147,9 +1162,9 @@ void LLTextEditor::addChar(llwchar wc)
LLWString wtext(getWText()); S32 shortCodePos; LLWString wtext(getWText()); S32 shortCodePos;
if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos)) if (LLEmojiHelper::isCursorInEmojiCode(wtext, mCursorPos, &shortCodePos))
{ {
const LLRect cursorRect = getLocalRectFromDocIndex(mCursorPos); const LLRect cursorRect = getLocalRectFromDocIndex(mCursorPos - 1);
const LLWString shortCode = wtext.substr(shortCodePos, mCursorPos); const LLWString shortCode = wtext.substr(shortCodePos, mCursorPos - shortCodePos);
LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, wstring_to_utf8str(shortCode)); LLEmojiHelper::instance().showHelper(this, cursorRect.mLeft, cursorRect.mTop, wstring_to_utf8str(shortCode), std::bind(&LLTextEditor::handleEmojiCommit, this, std::placeholders::_1));
} }
} }
......
...@@ -92,6 +92,8 @@ class LLTextEditor : ...@@ -92,6 +92,8 @@ class LLTextEditor :
static S32 spacesPerTab(); static S32 spacesPerTab();
void handleEmojiCommit(const LLWString& wstr);
// mousehandler overrides // mousehandler overrides
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment