diff options
Diffstat (limited to 'scene/gui/item_list.cpp')
-rw-r--r-- | scene/gui/item_list.cpp | 16 |
1 files changed, 14 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; |