diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index c7f0326ed49f324b6d95187a444c365df1fc4489..03071b554bfd5fb332008bafae03dd2cad4b3a89 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -959,11 +959,8 @@ void LLComboBox::onTextEntry(LLLineEditor* line_editor) void LLComboBox::updateSelection() { - LLWString left_wstring = mTextEntry->getWText().substr(0, mTextEntry->getCursor()); - // user-entered portion of string, based on assumption that any selected - // text was a result of auto-completion - LLWString user_wstring = mHasAutocompletedText ? left_wstring : mTextEntry->getWText(); - std::string full_string = mTextEntry->getText(); + const LLWString left_wstring = mTextEntry->getWText().substr(0, mTextEntry->getCursor()); + const std::string& full_string = mTextEntry->getText(); // go ahead and arrange drop down list on first typed character, even // though we aren't showing it... some code relies on prearrange @@ -991,6 +988,10 @@ void LLComboBox::updateSelection() } else // no matching items found { + // user-entered portion of string, based on assumption that any selected + // text was a result of auto-completion + const LLWString user_wstring = mHasAutocompletedText ? left_wstring : mTextEntry->getWText(); + mList->deselectAllItems(); mTextEntry->setText(wstring_to_utf8str(user_wstring)); // removes text added by autocompletion mTextEntry->setTentative(mTextEntryTentative); @@ -1138,6 +1139,19 @@ BOOL LLComboBox::selectItemRange( S32 first, S32 last ) return mList->selectItemRange(first, last); } +// virtual +BOOL LLComboBox::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if (mList->getVisible()) return mList->handleScrollWheel(x, y, clicks); + if (mAllowTextEntry) // We might be editable + if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text + return false; + + setCurrentByIndex(llclamp(getCurrentIndex() + clicks, 0, getItemCount() - 1)); + prearrangeList(); + onCommit(); + return true; +} static LLDefaultChildRegistry::Register<LLIconsComboBox> register_icons_combo_box("icons_combo_box"); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 7d38c051a5a9a527811612c47b69dee1ea36813f..704e375471360032ae9cab9dc005c0bb414019ed 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -107,6 +107,7 @@ class LLComboBox virtual BOOL handleToolTip(S32 x, S32 y, MASK mask); virtual BOOL handleKeyHere(KEY key, MASK mask); virtual BOOL handleUnicodeCharHere(llwchar uni_char); + BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) final override; // LLUICtrl interface virtual void clear(); // select nothing