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

Add emoji helper support to LLTextEditor

parent 063fe595
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "llmath.h" #include "llmath.h"
#include "llclipboard.h" #include "llclipboard.h"
#include "llemojihelper.h"
#include "llscrollbar.h" #include "llscrollbar.h"
#include "llstl.h" #include "llstl.h"
#include "llstring.h" #include "llstring.h"
...@@ -238,6 +239,7 @@ LLTextEditor::Params::Params() ...@@ -238,6 +239,7 @@ LLTextEditor::Params::Params()
default_color("default_color"), default_color("default_color"),
commit_on_focus_lost("commit_on_focus_lost", false), commit_on_focus_lost("commit_on_focus_lost", false),
show_context_menu("show_context_menu"), show_context_menu("show_context_menu"),
show_emoji_helper("show_emoji_helper"),
enable_tooltip_paste("enable_tooltip_paste") enable_tooltip_paste("enable_tooltip_paste")
{ {
addSynonym(prevalidate_callback, "text_type"); addSynonym(prevalidate_callback, "text_type");
...@@ -259,6 +261,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : ...@@ -259,6 +261,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mPrevalidateFunc(p.prevalidate_callback()), mPrevalidateFunc(p.prevalidate_callback()),
mContextMenu(NULL), mContextMenu(NULL),
mShowContextMenu(p.show_context_menu), mShowContextMenu(p.show_context_menu),
mShowEmojiHelper(p.show_emoji_helper),
mEnableTooltipPaste(p.enable_tooltip_paste), mEnableTooltipPaste(p.enable_tooltip_paste),
mPassDelete(FALSE), mPassDelete(FALSE),
mKeepSelectionOnReturn(false) mKeepSelectionOnReturn(false)
...@@ -501,6 +504,15 @@ void LLTextEditor::getSegmentsInRange(LLTextEditor::segment_vec_t& segments_out, ...@@ -501,6 +504,15 @@ void LLTextEditor::getSegmentsInRange(LLTextEditor::segment_vec_t& segments_out,
} }
} }
void LLTextEditor::setShowEmojiHelper(bool show) {
if (!mShowEmojiHelper)
{
LLEmojiHelper::instance().hideHelper(this);
}
mShowEmojiHelper = show;
}
BOOL LLTextEditor::selectionContainsLineBreaks() BOOL LLTextEditor::selectionContainsLineBreaks()
{ {
if (hasSelection()) if (hasSelection())
...@@ -930,6 +942,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask) ...@@ -930,6 +942,12 @@ BOOL LLTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
S32 LLTextEditor::execute( TextCmd* cmd ) S32 LLTextEditor::execute( TextCmd* cmd )
{ {
if (!mReadOnly && mShowEmojiHelper)
{
// Any change to our contents should always hide the helper
LLEmojiHelper::instance().hideHelper(this);
}
S32 delta = 0; S32 delta = 0;
if( cmd->execute(this, &delta) ) if( cmd->execute(this, &delta) )
{ {
...@@ -1124,6 +1142,17 @@ void LLTextEditor::addChar(llwchar wc) ...@@ -1124,6 +1142,17 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(mCursorPos + addChar( mCursorPos, wc )); setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
if (!mReadOnly && mShowEmojiHelper)
{
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));
}
}
if (!mReadOnly && mAutoreplaceCallback != NULL) if (!mReadOnly && mAutoreplaceCallback != NULL)
{ {
// autoreplace the text, if necessary // autoreplace the text, if necessary
...@@ -1774,6 +1803,11 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) ...@@ -1774,6 +1803,11 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )
} }
else else
{ {
if (!mReadOnly && mShowEmojiHelper && LLEmojiHelper::instance().handleKey(this, key, mask))
{
return TRUE;
}
if (mEnableTooltipPaste && if (mEnableTooltipPaste &&
LLToolTipMgr::instance().toolTipVisible() && LLToolTipMgr::instance().toolTipVisible() &&
KEY_TAB == key) KEY_TAB == key)
...@@ -1815,6 +1849,12 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask ) ...@@ -1815,6 +1849,12 @@ BOOL LLTextEditor::handleKeyHere(KEY key, MASK mask )
{ {
resetCursorBlink(); resetCursorBlink();
needsScroll(); needsScroll();
if (mShowEmojiHelper)
{
// Dismiss the helper whenever we handled a key that it didn't
LLEmojiHelper::instance().hideHelper(this);
}
} }
return handled; return handled;
......
...@@ -60,6 +60,7 @@ class LLTextEditor : ...@@ -60,6 +60,7 @@ class LLTextEditor :
ignore_tab, ignore_tab,
commit_on_focus_lost, commit_on_focus_lost,
show_context_menu, show_context_menu,
show_emoji_helper,
enable_tooltip_paste, enable_tooltip_paste,
auto_indent; auto_indent;
...@@ -201,6 +202,9 @@ class LLTextEditor : ...@@ -201,6 +202,9 @@ class LLTextEditor :
void setShowContextMenu(bool show) { mShowContextMenu = show; } void setShowContextMenu(bool show) { mShowContextMenu = show; }
bool getShowContextMenu() const { return mShowContextMenu; } bool getShowContextMenu() const { return mShowContextMenu; }
void setShowEmojiHelper(bool show);
bool getShowEmojiHelper() const { return mShowEmojiHelper; }
void setPassDelete(BOOL b) { mPassDelete = b; } void setPassDelete(BOOL b) { mPassDelete = b; }
protected: protected:
...@@ -317,6 +321,7 @@ class LLTextEditor : ...@@ -317,6 +321,7 @@ class LLTextEditor :
BOOL mAllowEmbeddedItems; BOOL mAllowEmbeddedItems;
bool mShowContextMenu; bool mShowContextMenu;
bool mShowEmojiHelper;
bool mEnableTooltipPaste; bool mEnableTooltipPaste;
bool mPassDelete; bool mPassDelete;
bool mKeepSelectionOnReturn; // disabling of removing selected text after pressing of Enter bool mKeepSelectionOnReturn; // disabling of removing selected text after pressing of Enter
......
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