summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llkeywords.cpp2
-rw-r--r--indra/llui/llpanel.cpp8
-rw-r--r--indra/llui/llpanel.h9
-rw-r--r--indra/llui/llspinctrl.cpp73
4 files changed, 61 insertions, 31 deletions
diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp
index db1611abb5..ede32084d0 100644
--- a/indra/llui/llkeywords.cpp
+++ b/indra/llui/llkeywords.cpp
@@ -245,7 +245,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW
return;
}
- S32 text_len = wtext.size();
+ S32 text_len = wtext.size() + 1;
seg_list->push_back( new LLNormalTextSegment( defaultColor, 0, text_len, editor ) );
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 0b987bfcb5..c81be6086a 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -58,6 +58,11 @@
static LLDefaultChildRegistry::Register<LLPanel> r1("panel", &LLPanel::fromXML);
+LLPanel::LocalizedString::LocalizedString()
+: name("name"),
+ value("value")
+{}
+
const LLPanel::Params& LLPanel::getDefaultParams()
{
return LLUICtrlFactory::getDefaultParams<LLPanel>();
@@ -675,6 +680,9 @@ BOOL LLPanel::childHasFocus(const std::string& id)
}
// *TODO: Deprecate; for backwards compatability only:
+// Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)),
+// which takes a generic slot. Or use mCommitCallbackRegistrar.add() with
+// a named callback and reference it in XML.
void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data)
{
LLUICtrl* child = findChild<LLUICtrl>(id);
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 28cd4d2799..3f1d1fdc5d 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -63,10 +63,7 @@ public:
Mandatory<std::string> name;
Mandatory<std::string> value;
- LocalizedString()
- : name("name"),
- value("value")
- {}
+ LocalizedString();
};
struct Params
@@ -185,7 +182,11 @@ public:
BOOL childHasFocus(const std::string& id);
// *TODO: Deprecate; for backwards compatability only:
+ // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)),
+ // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with
+ // a named callback and reference it in XML.
void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data);
+
void childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb );
void childSetColor(const std::string& id, const LLColor4& color);
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 7b96446fa1..3a96bc8f93 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -174,23 +174,33 @@ void LLSpinCtrl::onUpBtn( const LLSD& data )
{
if( getEnabled() )
{
- // use getValue()/setValue() to force reload from/to control
- F32 val = (F32)getValue().asReal() + mIncrement;
- val = clamp_precision(val, mPrecision);
- val = llmin( val, mMaxValue );
-
- F32 saved_val = (F32)getValue().asReal();
- setValue(val);
- if( !mValidateSignal( this, val ) )
+ std::string text = mEditor->getText();
+ if( LLLineEditor::postvalidateFloat( text ) )
{
- setValue( saved_val );
- reportInvalidData();
- updateEditor();
- return;
- }
+
+ LLLocale locale(LLLocale::USER_LOCALE);
+ F32 cur_val = (F32) atof(text.c_str());
+
+ // use getValue()/setValue() to force reload from/to control
+ F32 val = cur_val + mIncrement;
+ val = clamp_precision(val, mPrecision);
+ val = llmin( val, mMaxValue );
+ if (val < mMinValue) val = mMinValue;
+ if (val > mMaxValue) val = mMaxValue;
+
+ F32 saved_val = (F32)getValue().asReal();
+ setValue(val);
+ if( !mValidateSignal( this, val ) )
+ {
+ setValue( saved_val );
+ reportInvalidData();
+ updateEditor();
+ return;
+ }
updateEditor();
onCommit();
+ }
}
}
@@ -198,22 +208,33 @@ void LLSpinCtrl::onDownBtn( const LLSD& data )
{
if( getEnabled() )
{
- F32 val = (F32)getValue().asReal() - mIncrement;
- val = clamp_precision(val, mPrecision);
- val = llmax( val, mMinValue );
-
- F32 saved_val = (F32)getValue().asReal();
- setValue(val);
- if( !mValidateSignal( this, val ) )
+ std::string text = mEditor->getText();
+ if( LLLineEditor::postvalidateFloat( text ) )
{
- setValue( saved_val );
- reportInvalidData();
+
+ LLLocale locale(LLLocale::USER_LOCALE);
+ F32 cur_val = (F32) atof(text.c_str());
+
+ F32 val = cur_val - mIncrement;
+ val = clamp_precision(val, mPrecision);
+ val = llmax( val, mMinValue );
+
+ if (val < mMinValue) val = mMinValue;
+ if (val > mMaxValue) val = mMaxValue;
+
+ F32 saved_val = (F32)getValue().asReal();
+ setValue(val);
+ if( !mValidateSignal( this, val ) )
+ {
+ setValue( saved_val );
+ reportInvalidData();
+ updateEditor();
+ return;
+ }
+
updateEditor();
- return;
+ onCommit();
}
-
- updateEditor();
- onCommit();
}
}