diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index edd26fb1a1..7840b84d8b 100755 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -937,7 +937,10 @@ void LLComboBox::updateSelection() mTextEntry->setTentative(FALSE); mLastSelectedIndex = mList->getFirstSelectedIndex(); } - else if (mList->selectItemByPrefix(left_wstring, FALSE)) + // Allow fulltext search in comboboxes + //else if (mList->selectItemByPrefix(left_wstring, FALSE)) + else if (!LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemByPrefix(left_wstring, FALSE)) + // { LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel()); LLWString wtext = left_wstring + selected_item.substr(left_wstring.size(), selected_item.size()); @@ -948,6 +951,18 @@ void LLComboBox::updateSelection() mHasAutocompletedText = TRUE; mLastSelectedIndex = mList->getFirstSelectedIndex(); } + // Allow fulltext search in comboboxes + else if (LLControlGroup::getInstance("Global")->getBOOL("FSComboboxSubstringSearch") && mList->selectItemBySubstring(left_wstring, FALSE)) + { + LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel()); + mTextEntry->setText(wstring_to_utf8str(left_wstring) + " (" + getSelectedItemLabel() + ")"); + mTextEntry->setSelection(left_wstring.size(), mTextEntry->getWText().size()); + mTextEntry->endSelection(); + mTextEntry->setTentative(FALSE); + mHasAutocompletedText = TRUE; + mLastSelectedIndex = mList->getFirstSelectedIndex(); + } + // else // no matching items found { mList->deselectAllItems(); diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index c352368bed..e14ca158a9 100755 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1318,6 +1318,13 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const std::string& target, BOOL case_s // Selects first enabled item that has a name where the name's first part matched the target string. // Returns false if item not found. BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sensitive) +// Allow selection by substring match +{ + return selectItemByStringMatch(target, true, case_sensitive); +} + +BOOL LLScrollListCtrl::selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive) +// { BOOL found = FALSE; @@ -1369,7 +1376,18 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen LLWString trimmed_label = item_label; LLWStringUtil::trim(trimmed_label); - BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; + // Allow selection by substring match + //BOOL select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; + BOOL select; + if (prefix_match) + { + select = item->getEnabled() && trimmed_label.compare(0, target_trimmed.size(), target_trimmed) == 0; + } + else + { + select = item->getEnabled() && trimmed_label.find(target_trimmed) != std::string::npos; + } + // if (select) { @@ -1391,6 +1409,19 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen return found; } +// Allow selection by substring match +BOOL LLScrollListCtrl::selectItemBySubstring(const std::string& target, BOOL case_sensitive) +{ + return selectItemBySubstring(utf8str_to_wstring(target), case_sensitive); +} + +// Returns false if item not found. +BOOL LLScrollListCtrl::selectItemBySubstring(const LLWString& target, BOOL case_sensitive) +{ + return selectItemByStringMatch(target, false, case_sensitive); +} +// + const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const { LLScrollListItem* item; diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index f6e9e7c947..9aa5e5380f 100755 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -249,6 +249,11 @@ public: BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); // FALSE if item not found BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE); BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE); + // Allow selection by substring match + BOOL selectItemBySubstring(const std::string& target, BOOL case_sensitive = TRUE); + BOOL selectItemBySubstring(const LLWString& target, BOOL case_sensitive = TRUE); + BOOL selectItemByStringMatch(const LLWString& target, bool prefix_match, BOOL case_sensitive = TRUE); + // LLScrollListItem* getItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); const std::string getSelectedItemLabel(S32 column = 0) const; LLSD getSelectedValue(); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c776a5e301..bd6c935911 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -22844,6 +22844,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value 1 + FSComboboxSubstringSearch + + Comment + Allows fulltext search on comboboxes + Persist + 1 + Type + Boolean + Value + 1 +