summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/item_list.cpp16
-rw-r--r--scene/gui/item_list.h1
2 files changed, 15 insertions, 2 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 5379836746..d63c483ef9 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1245,6 +1245,19 @@ real_t ItemList::get_icon_scale() const {
return icon_scale;
}
+Vector<int> ItemList::get_selected_items() {
+ Vector<int> selected;
+ for (int i = 0; i < items.size(); i++) {
+ if (items[i].selected) {
+ selected.push_back(i);
+ if (this->select_mode == SELECT_SINGLE) {
+ break;
+ }
+ }
+ }
+ return selected;
+}
+
void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
@@ -1277,6 +1290,7 @@ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
@@ -1330,8 +1344,6 @@ void ItemList::_bind_methods(){
ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
}
-
-
ItemList::ItemList() {
current=-1;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index aa6dd64c50..e1902d1c1f 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -144,6 +144,7 @@ public:
void select(int p_idx,bool p_single=true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
+ Vector<int> get_selected_items();
void set_current(int p_current);
int get_current() const;