diff options
| author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2026-04-01 19:23:41 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-01 19:23:41 +0300 |
| commit | b4f1072a492f5baa8338bd1a5dc2d87ccfacc086 (patch) | |
| tree | 40c12699f5642475ff71461f2b6b08081a834e8b | |
| parent | a77156ebbdfa61a9c88437a61b78f986e191ac80 (diff) | |
#5367 Leap API support for combo boxes
| -rw-r--r-- | indra/llui/llcombobox.cpp | 33 | ||||
| -rw-r--r-- | indra/llui/llcombobox.h | 4 | ||||
| -rw-r--r-- | indra/newview/lluilistener.cpp | 24 | ||||
| -rw-r--r-- | indra/newview/lluilistener.h | 1 |
4 files changed, 62 insertions, 0 deletions
diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index ae676251ff..01463b4962 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -1323,6 +1323,39 @@ bool LLComboBox::selectItemRange( S32 first, S32 last ) return mList->selectItemRange(first, last); } +void LLComboBox::addInfo(LLSD& info) +{ + LLUICtrl::addInfo(info); + + if (mList && mList->getItemCount() > 0) + { + LLSD items_array; + std::vector<LLScrollListItem*> item_list = mList->getAllData(); + for (std::vector<LLScrollListItem*>::iterator iter = item_list.begin(); iter != item_list.end(); ++iter) + { + if (LLScrollListItem* item = *iter) + { + LLSD item_info; + item_info["value"] = item->getValue(); + if (item->getNumColumns() > 0) + { + if (LLScrollListCell* cell = item->getColumn(0)) + { + item_info["label"] = cell->getValue(); + } + } + items_array.append(item_info); + } + } + info["items"] = items_array; + info["item_count"] = mList->getItemCount(); + info["current_selection"] = getSelectedItemLabel(); + } + else + { + info["item_count"] = 0; + } +} static LLDefaultChildRegistry::Register<LLIconsComboBox> register_icons_combo_box("icons_combo_box"); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index d6ea1202d3..dad60ffb65 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -219,6 +219,10 @@ public: void setButtonVisible(bool visible); + // Populates the provided LLSD with combo box-specific information(list of items, item count, current selection label) + // also includes base LLUICtrl information via parent class + void addInfo(LLSD & info); + void onButtonMouseDown(); void onListMouseUp(); void onItemSelected(const LLSD& data); diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index beae71e7bf..d95560b306 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -37,6 +37,7 @@ #include "llui.h" // getRootView(), resolvePath() #include "lluictrl.h" #include "llerror.h" +#include "llcombobox.h" LLUIListener::LLUIListener(): @@ -55,6 +56,12 @@ LLUIListener::LLUIListener(): "current value as [\"value\"] reply.", &LLUIListener::getValue, LLSDMap("path", LLSD())("reply", LLSD())); + + add("setSelectedByValue", + "For the combobox identified by the path in [\"path\"] set selection by [\"value\"],\n" + "and return result as [\"reply\"]", + &LLUIListener::setSelectedByValue, + llsd::map("path", LLSD(), "value", LLSD(), "reply", LLSD())); } void LLUIListener::call(const LLSD& event) const @@ -99,3 +106,20 @@ void LLUIListener::getValue(const LLSD&event) const sendReply(reply, event); } + +void LLUIListener::setSelectedByValue(const LLSD& event) const +{ + Response response(LLSD(), event); + std::string path(event["path"]); + LLComboBox* combo_ctrl = dynamic_cast<LLComboBox*>(LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path)); + if (combo_ctrl) + { + response.setResponse(combo_ctrl->setSelectedByValue(event["value"], true)); + return; + } + else + { + LL_WARNS() << "Specified combobox doesn't exist: " << path << LL_ENDL; + } + response.setResponse(false); +} diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h index 70455c2c68..228e67ae26 100644 --- a/indra/newview/lluilistener.h +++ b/indra/newview/lluilistener.h @@ -42,6 +42,7 @@ public: private: void call(const LLSD& event) const; void getValue(const LLSD&event) const; + void setSelectedByValue(const LLSD& event) const; }; #endif /* ! defined(LL_LLUILISTENER_H) */ |
