summaryrefslogtreecommitdiff
path: root/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorrichard <none@none>2010-02-05 11:32:33 -0800
committerrichard <none@none>2010-02-05 11:32:33 -0800
commitddfc6efbeeda5d2b08888a7ae0f04df242326e26 (patch)
tree5bbfba7e0afaf66a83e5db1b1a67c2a0462fe12b /indra/llui/lltexteditor.cpp
parentfed6c9eb0fa58559c13729b65ecee181f58f3c69 (diff)
EXT-5025 - Tooltips block mouse clicks
EXT-4547 [BSI] it is possible to highlight multiple layers of chat EXT-3844 Mouse wheel camera zoom is not reflected on View popup slider EXT-3103 Add an option to restrict entering non-ascii symbols in text editor. reviewed by Leyla
Diffstat (limited to 'indra/llui/lltexteditor.cpp')
-rw-r--r--indra/llui/lltexteditor.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 3fdb48b3ca..e196abc89a 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -237,13 +237,16 @@ private:
///////////////////////////////////////////////////////////////////
LLTextEditor::Params::Params()
: default_text("default_text"),
+ prevalidate_callback("prevalidate_callback"),
embedded_items("embedded_items", false),
ignore_tab("ignore_tab", true),
handle_edit_keys_directly("handle_edit_keys_directly", false),
show_line_numbers("show_line_numbers", false),
default_color("default_color"),
commit_on_focus_lost("commit_on_focus_lost", false)
-{}
+{
+ addSynonym(prevalidate_callback, "text_type");
+}
LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
LLTextBase(p),
@@ -258,6 +261,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mMouseDownX(0),
mMouseDownY(0),
mTabsToNextField(p.ignore_tab),
+ mPrevalidateFunc(p.prevalidate_callback()),
mContextMenu(NULL)
{
mDefaultFont = p.font;
@@ -318,9 +322,20 @@ LLTextEditor::~LLTextEditor()
void LLTextEditor::setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params)
{
+ // validate incoming text if necessary
+ if (mPrevalidateFunc)
+ {
+ LLWString test_text = utf8str_to_wstring(utf8str);
+ if (!mPrevalidateFunc(test_text))
+ {
+ // not valid text, nothing to do
+ return;
+ }
+ }
+
blockUndo();
deselect();
-
+
LLTextBase::setText(utf8str, input_params);
resetDirty();
@@ -909,6 +924,21 @@ S32 LLTextEditor::execute( TextCmd* cmd )
// Push the new command is now on the top (front) of the undo stack.
mUndoStack.push_front(cmd);
mLastCmd = cmd;
+
+ bool need_to_rollback = mPrevalidateFunc
+ && !mPrevalidateFunc(getViewModel()->getDisplay());
+ if (need_to_rollback)
+ {
+ // get rid of this last command and clean up undo stack
+ undo();
+
+ // remove any evidence of this command from redo history
+ mUndoStack.pop_front();
+ delete cmd;
+
+ // failure, nothing changed
+ delta = 0;
+ }
}
else
{
@@ -1032,7 +1062,21 @@ S32 LLTextEditor::addChar(S32 pos, llwchar wc)
if (mLastCmd && mLastCmd->canExtend(pos))
{
S32 delta = 0;
+ if (mPrevalidateFunc)
+ {
+ // get a copy of current text contents
+ LLWString test_string(getViewModel()->getDisplay());
+
+ // modify text contents as if this addChar succeeded
+ llassert(pos <= (S32)test_string.size());
+ test_string.insert(pos, 1, wc);
+ if (!mPrevalidateFunc( test_string))
+ {
+ return 0;
+ }
+ }
mLastCmd->extendAndExecute(this, pos, wc, &delta);
+
return delta;
}
else