diff options
Diffstat (limited to 'linden/indra/llui/lllineeditor.cpp')
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 12d1929..9c8ee94 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -41,6 +41,7 @@ | |||
41 | #include "llgl.h" | 41 | #include "llgl.h" |
42 | #include "lltimer.h" | 42 | #include "lltimer.h" |
43 | 43 | ||
44 | #include "llcalc.h" | ||
44 | //#include "llclipboard.h" | 45 | //#include "llclipboard.h" |
45 | #include "llcontrol.h" | 46 | #include "llcontrol.h" |
46 | #include "llbutton.h" | 47 | #include "llbutton.h" |
@@ -129,6 +130,7 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, | |||
129 | mDrawAsterixes( FALSE ), | 130 | mDrawAsterixes( FALSE ), |
130 | mHandleEditKeysDirectly( FALSE ), | 131 | mHandleEditKeysDirectly( FALSE ), |
131 | mSelectAllonFocusReceived( FALSE ), | 132 | mSelectAllonFocusReceived( FALSE ), |
133 | mSelectAllonCommit( TRUE ), | ||
132 | mPassDelete(FALSE), | 134 | mPassDelete(FALSE), |
133 | mReadOnly(FALSE), | 135 | mReadOnly(FALSE), |
134 | mImage( sImage ), | 136 | mImage( sImage ), |
@@ -226,7 +228,10 @@ void LLLineEditor::onCommit() | |||
226 | updateHistory(); | 228 | updateHistory(); |
227 | 229 | ||
228 | LLUICtrl::onCommit(); | 230 | LLUICtrl::onCommit(); |
229 | selectAll(); | 231 | |
232 | // Selection on commit needs to be turned off when evaluating maths | ||
233 | // expressions, to allow indication of the error position | ||
234 | if (mSelectAllonCommit) selectAll(); | ||
230 | } | 235 | } |
231 | 236 | ||
232 | 237 | ||
@@ -2082,6 +2087,32 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str) | |||
2082 | return rv; | 2087 | return rv; |
2083 | } | 2088 | } |
2084 | 2089 | ||
2090 | BOOL LLLineEditor::evaluateFloat() | ||
2091 | { | ||
2092 | bool success; | ||
2093 | F32 result = 0.f; | ||
2094 | std::string expr = getText(); | ||
2095 | |||
2096 | success = LLCalc::getInstance()->evalString(expr, result); | ||
2097 | |||
2098 | if (!success) | ||
2099 | { | ||
2100 | // Move the cursor to near the error on failure | ||
2101 | setCursor(LLCalc::getInstance()->getLastErrorPos()); | ||
2102 | // *TODO: Translated error message indicating the type of error? Select error text? | ||
2103 | } | ||
2104 | else | ||
2105 | { | ||
2106 | // Replace the expression with the result | ||
2107 | std::ostringstream result_str; | ||
2108 | result_str << result; | ||
2109 | setText(result_str.str()); | ||
2110 | selectAll(); | ||
2111 | } | ||
2112 | |||
2113 | return success; | ||
2114 | } | ||
2115 | |||
2085 | void LLLineEditor::onMouseCaptureLost() | 2116 | void LLLineEditor::onMouseCaptureLost() |
2086 | { | 2117 | { |
2087 | endSelection(); | 2118 | endSelection(); |