summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorJean Jung <jean.jung@rocketmail.com>2016-06-28 14:09:17 -0300
committerJean Jung <jean.jung@rocketmail.com>2016-06-28 14:09:17 -0300
commit2fd9b77828bcc7c22594c7037db17efd11ba1909 (patch)
tree88b9b74c2e9481630916fc848e81c41ec56eab88 /scene/gui
parentcf6450043d8815c5708644a097e3af85a1b120b6 (diff)
itemlist-get_selected_items
Diffstat (limited to 'scene/gui')
-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;