summaryrefslogtreecommitdiff
path: root/indra/llui/llcombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llcombobox.cpp')
-rw-r--r--indra/llui/llcombobox.cpp76
1 files changed, 51 insertions, 25 deletions
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index 6e2af4c853..b64794a244 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -107,7 +107,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
button_params.follows.flags(FOLLOWS_LEFT|FOLLOWS_BOTTOM|FOLLOWS_RIGHT);
button_params.rect(p.rect);
- if(mAllowTextEntry)
+ if (mAllowTextEntry)
{
button_params.pad_right(2);
}
@@ -121,7 +121,7 @@ LLComboBox::LLComboBox(const LLComboBox::Params& p)
mButton = LLUICtrlFactory::create<LLButton>(button_params);
- if(mAllowTextEntry)
+ if (mAllowTextEntry)
{
//redo to compensate for button hack that leaves space for a character
//unless it is a "minimal combobox"(drop down)
@@ -207,14 +207,27 @@ void LLComboBox::clear()
void LLComboBox::onCommit()
{
- if (mAllowTextEntry && getCurrentIndex() != -1)
+ if (LLScrollListItem* item = mList->getFirstSelected())
{
- // we have selected an existing item, blitz the manual text entry with
- // the properly capitalized item
- mTextEntry->setValue(getSimple());
- mTextEntry->setTentative(false);
+ if (mAllowTextEntry && mTextEntry)
+ {
+ // we have selected an existing item, blitz the manual text entry with
+ // the properly capitalized item
+ LLSD label = item->getColumn(0)->getValue();
+ mTextEntry->setValue(label);
+ mTextEntry->setTentative(false);
+ }
+ setControlValue(item->getValue());
+ }
+ else if (mAllowTextEntry)
+ {
+ setControlValue(mTextEntry->getValue());
}
- setControlValue(getValue());
+ else
+ {
+ setControlValue(LLSD());
+ }
+
LLUICtrl::onCommit();
}
@@ -349,6 +362,13 @@ bool LLComboBox::setSimple(const LLStringExplicit& name)
// virtual
void LLComboBox::setValue(const LLSD& value)
{
+ if (LLScrollListItem* item = mList->getFirstSelected())
+ {
+ LLSD item_value = item->getValue();
+ if (item_value.asStringRef() == value.asStringRef())
+ return;
+ }
+
bool found = mList->selectByValue(value);
if (found)
{
@@ -372,10 +392,8 @@ const std::string LLComboBox::getSimple() const
{
return mTextEntry->getText();
}
- else
- {
- return res;
- }
+
+ return res;
}
const std::string LLComboBox::getSelectedItemLabel(S32 column) const
@@ -386,24 +404,22 @@ const std::string LLComboBox::getSelectedItemLabel(S32 column) const
// virtual
LLSD LLComboBox::getValue() const
{
- LLScrollListItem* item = mList->getFirstSelected();
- if( item )
+ if (LLScrollListItem* item = mList->getFirstSelected())
{
return item->getValue();
}
- else if (mAllowTextEntry)
+
+ if (mAllowTextEntry)
{
return mTextEntry->getValue();
}
- else
- {
- return LLSD();
- }
+
+ return LLSD();
}
void LLComboBox::setLabel(const LLStringExplicit& name)
{
- if ( mTextEntry )
+ if (mTextEntry)
{
mTextEntry->setText(name);
if (mList->selectItemByLabel(name, false))
@@ -500,13 +516,23 @@ void LLComboBox::setButtonVisible(bool visible)
bool LLComboBox::setCurrentByIndex(S32 index)
{
- bool found = mList->selectNthItem(index);
- if (found)
+ if (LLScrollListItem* item = mList->getItemByIndex(index))
{
- setLabel(getSelectedItemLabel());
- mLastSelectedIndex = index;
+ if (item->getEnabled())
+ {
+ mList->selectItem(item, -1, true);
+ if (mTextEntry)
+ {
+ LLSD::String label = item->getColumn(0)->getValue().asString();
+ mTextEntry->setText(label);
+ mTextEntry->setTentative(false);
+ }
+ mLastSelectedIndex = index;
+ return true;
+ }
}
- return found;
+
+ return false;
}
S32 LLComboBox::getCurrentIndex() const