aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/llui/lllineeditor.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp
index 5441d0a..7d91ece 100644
--- a/linden/indra/llui/lllineeditor.cpp
+++ b/linden/indra/llui/lllineeditor.cpp
@@ -2621,28 +2621,37 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str)
2621 2621
2622BOOL LLLineEditor::evaluateFloat() 2622BOOL LLLineEditor::evaluateFloat()
2623{ 2623{
2624 bool success; 2624 bool success = false;
2625 F32 result = 0.f;
2626 std::string expr = getText(); 2625 std::string expr = getText();
2627 LLStringUtil::toUpper(expr); 2626 LLStringUtil::toUpper(expr);
2628 2627
2629 success = LLCalc::getInstance()->evalString(expr, result); 2628 // user deleted the contents, nothing to evaluate -- MC
2630 2629 if (expr.empty())
2631 if (!success)
2632 { 2630 {
2633 // Move the cursor to near the error on failure 2631 return success;
2634 setCursor(LLCalc::getInstance()->getLastErrorPos());
2635 // *TODO: Translated error message indicating the type of error? Select error text?
2636 } 2632 }
2637 else 2633 else
2638 { 2634 {
2639 // Replace the expression with the result 2635 F32 result = 0.f;
2640 std::string result_str = llformat("%f",result); 2636 success = LLCalc::getInstance()->evalString(expr, result);
2641 setText(result_str);
2642 selectAll();
2643 }
2644 2637
2645 return success; 2638 if (!success)
2639 {
2640 // Move the cursor to near the error on failure
2641 setCursor(LLCalc::getInstance()->getLastErrorPos());
2642 // *TODO: Translated error message indicating the type of error? Select error text?
2643 }
2644 else
2645 {
2646 // Replace the expression with the result
2647 std::ostringstream result_str;
2648 result_str << result;
2649 setText(result_str.str());
2650 selectAll();
2651 }
2652
2653 return success;
2654 }
2646} 2655}
2647 2656
2648void LLLineEditor::onMouseCaptureLost() 2657void LLLineEditor::onMouseCaptureLost()