diff options
author | Oz Linden <oz@lindenlab.com> | 2011-07-11 16:52:00 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-07-11 16:52:00 -0400 |
commit | 44c7c6feaa824f4049d326965cb066e76ebefee3 (patch) | |
tree | 71a8a35701a486b44b969d14306aad8953fa8286 /indra/llui/lllineeditor.cpp | |
parent | 121d004b324c976acc6ac4f94f6dbe2ae54040eb (diff) | |
parent | 57c30517817a6458edab6bfdfad7d7112467ca48 (diff) |
merge changes for storm-1315
Diffstat (limited to 'indra/llui/lllineeditor.cpp')
-rw-r--r-- | indra/llui/lllineeditor.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 123997e5e9..06fbc0f234 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -37,6 +37,7 @@ #include "llgl.h" #include "lltimer.h" +#include "llcalc.h" //#include "llclipboard.h" #include "llcontrol.h" #include "llbutton.h" @@ -133,6 +134,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mIgnoreTab( p.ignore_tab ), mDrawAsterixes( p.is_password ), mSelectAllonFocusReceived( p.select_on_focus ), + mSelectAllonCommit( TRUE ), mPassDelete(FALSE), mReadOnly(FALSE), mBgImage( p.background_image ), @@ -230,7 +232,10 @@ void LLLineEditor::onCommit() setControlValue(getValue()); LLUICtrl::onCommit(); - selectAll(); + + // Selection on commit needs to be turned off when evaluating maths + // expressions, to allow indication of the error position + if (mSelectAllonCommit) selectAll(); } // Returns TRUE if user changed value at all @@ -2072,6 +2077,32 @@ BOOL LLLineEditor::postvalidateFloat(const std::string &str) return success; } +BOOL LLLineEditor::evaluateFloat() +{ + bool success; + F32 result = 0.f; + std::string expr = getText(); + LLStringUtil::toUpper(expr); + + success = LLCalc::getInstance()->evalString(expr, result); + + if (!success) + { + // Move the cursor to near the error on failure + setCursor(LLCalc::getInstance()->getLastErrorPos()); + // *TODO: Translated error message indicating the type of error? Select error text? + } + else + { + // Replace the expression with the result + std::string result_str = llformat("%f",result); + setText(result_str); + selectAll(); + } + + return success; +} + void LLLineEditor::onMouseCaptureLost() { endSelection(); |