diff options
author | callum_linden <none@none> | 2017-08-22 14:32:04 -0700 |
---|---|---|
committer | callum_linden <none@none> | 2017-08-22 14:32:04 -0700 |
commit | b5dbb9c52aa8f9379662f1ff1169adadcf8ac5f8 (patch) | |
tree | 438d099240df63608825568d162874e186835994 /indra/llui/llspinctrl.cpp | |
parent | 8e6751efced8d9f5ede5ec5d954ff809d56d1162 (diff) | |
parent | 58176de9574164e31790a148d9b5489a129fc961 (diff) |
Automated merge with head of ll/viewer64 after DRTVWR-439 merge
Diffstat (limited to 'indra/llui/llspinctrl.cpp')
-rw-r--r-- | indra/llui/llspinctrl.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index d49e216898..f6831c6d5e 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -130,6 +130,7 @@ LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p) params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM); mEditor = LLUICtrlFactory::create<LLLineEditor> (params); mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this )); + mEditor->setFocusLostCallback( boost::bind(&LLSpinCtrl::onEditorLostFocus, _1, this )); if (p.allow_digits_only) { mEditor->setPrevalidateInput(LLTextValidate::validateNonNegativeS32NoSpace); @@ -239,6 +240,31 @@ void LLSpinCtrl::onEditorGainFocus( LLFocusableElement* caller, void *userdata ) self->onFocusReceived(); } +// static +void LLSpinCtrl::onEditorLostFocus( LLFocusableElement* caller, void *userdata ) +{ + LLSpinCtrl* self = (LLSpinCtrl*) userdata; + llassert( caller == self->mEditor ); + + self->onFocusLost(); + + std::string text = self->mEditor->getText(); + + LLLocale locale(LLLocale::USER_LOCALE); + F32 val = (F32)atof(text.c_str()); + + F32 saved_val = self->getValueF32(); + if (saved_val != val && !self->mEditor->isDirty()) + { + // Editor was focused when value update arrived, string + // in editor is different from one in spin control. + // Since editor is not dirty, it won't commit, so either + // attempt to commit value from editor or revert to a more + // recent value from spin control + self->updateEditor(); + } +} + void LLSpinCtrl::setValue(const LLSD& value ) { F32 v = (F32)value.asReal(); |