Skip to content

Commit b4f1072

Browse files
#5367 Leap API support for combo boxes
1 parent a77156e commit b4f1072

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

indra/llui/llcombobox.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,39 @@ bool LLComboBox::selectItemRange( S32 first, S32 last )
13231323
return mList->selectItemRange(first, last);
13241324
}
13251325

1326+
void LLComboBox::addInfo(LLSD& info)
1327+
{
1328+
LLUICtrl::addInfo(info);
1329+
1330+
if (mList && mList->getItemCount() > 0)
1331+
{
1332+
LLSD items_array;
1333+
std::vector<LLScrollListItem*> item_list = mList->getAllData();
1334+
for (std::vector<LLScrollListItem*>::iterator iter = item_list.begin(); iter != item_list.end(); ++iter)
1335+
{
1336+
if (LLScrollListItem* item = *iter)
1337+
{
1338+
LLSD item_info;
1339+
item_info["value"] = item->getValue();
1340+
if (item->getNumColumns() > 0)
1341+
{
1342+
if (LLScrollListCell* cell = item->getColumn(0))
1343+
{
1344+
item_info["label"] = cell->getValue();
1345+
}
1346+
}
1347+
items_array.append(item_info);
1348+
}
1349+
}
1350+
info["items"] = items_array;
1351+
info["item_count"] = mList->getItemCount();
1352+
info["current_selection"] = getSelectedItemLabel();
1353+
}
1354+
else
1355+
{
1356+
info["item_count"] = 0;
1357+
}
1358+
}
13261359

13271360
static LLDefaultChildRegistry::Register<LLIconsComboBox> register_icons_combo_box("icons_combo_box");
13281361

indra/llui/llcombobox.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ class LLComboBox
219219

220220
void setButtonVisible(bool visible);
221221

222+
// Populates the provided LLSD with combo box-specific information(list of items, item count, current selection label)
223+
// also includes base LLUICtrl information via parent class
224+
void addInfo(LLSD & info);
225+
222226
void onButtonMouseDown();
223227
void onListMouseUp();
224228
void onItemSelected(const LLSD& data);

indra/newview/lluilistener.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "llui.h" // getRootView(), resolvePath()
3838
#include "lluictrl.h"
3939
#include "llerror.h"
40+
#include "llcombobox.h"
4041

4142

4243
LLUIListener::LLUIListener():
@@ -55,6 +56,12 @@ LLUIListener::LLUIListener():
5556
"current value as [\"value\"] reply.",
5657
&LLUIListener::getValue,
5758
LLSDMap("path", LLSD())("reply", LLSD()));
59+
60+
add("setSelectedByValue",
61+
"For the combobox identified by the path in [\"path\"] set selection by [\"value\"],\n"
62+
"and return result as [\"reply\"]",
63+
&LLUIListener::setSelectedByValue,
64+
llsd::map("path", LLSD(), "value", LLSD(), "reply", LLSD()));
5865
}
5966

6067
void LLUIListener::call(const LLSD& event) const
@@ -99,3 +106,20 @@ void LLUIListener::getValue(const LLSD&event) const
99106

100107
sendReply(reply, event);
101108
}
109+
110+
void LLUIListener::setSelectedByValue(const LLSD& event) const
111+
{
112+
Response response(LLSD(), event);
113+
std::string path(event["path"]);
114+
LLComboBox* combo_ctrl = dynamic_cast<LLComboBox*>(LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path));
115+
if (combo_ctrl)
116+
{
117+
response.setResponse(combo_ctrl->setSelectedByValue(event["value"], true));
118+
return;
119+
}
120+
else
121+
{
122+
LL_WARNS() << "Specified combobox doesn't exist: " << path << LL_ENDL;
123+
}
124+
response.setResponse(false);
125+
}

indra/newview/lluilistener.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class LLUIListener: public LLEventAPI
4242
private:
4343
void call(const LLSD& event) const;
4444
void getValue(const LLSD&event) const;
45+
void setSelectedByValue(const LLSD& event) const;
4546
};
4647

4748
#endif /* ! defined(LL_LLUILISTENER_H) */

0 commit comments

Comments
 (0)