itemlist-get_selected_items
This commit is contained in:
parent
cf6450043d
commit
2fd9b77828
2 changed files with 15 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue