summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-08 11:48:33 +0100
committerGitHub <noreply@github.com>2022-01-08 11:48:33 +0100
commit13d25f99805c7c970708277ceae6ae3b84893642 (patch)
tree2057bd301f172fd37f310a6b602867abf423b08f /scene
parentcb7daddbebac8dbb354e0e92f8e16013fcb22055 (diff)
parentcf5cad7126e846d99f4549fd0b9fe499f27a190c (diff)
Merge pull request #56608 from jmb462/itemlist_item_selectable
Expose selectable property of ItemList's Item and set default to true
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/item_list.cpp10
-rw-r--r--scene/gui/item_list.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index b0dc12d046..0cb3249c1d 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1492,6 +1492,9 @@ bool ItemList::_set(const StringName &p_name, const Variant &p_value) {
} else if (components[1] == "disabled") {
set_item_disabled(item_index, p_value);
return true;
+ } else if (components[1] == "selectable") {
+ set_item_selectable(item_index, p_value);
+ return true;
}
}
#ifndef DISABLE_DEPRECATED
@@ -1528,6 +1531,9 @@ bool ItemList::_get(const StringName &p_name, Variant &r_ret) const {
} else if (components[1] == "disabled") {
r_ret = is_item_disabled(item_index);
return true;
+ } else if (components[1] == "selectable") {
+ r_ret = is_item_selectable(item_index);
+ return true;
}
}
return false;
@@ -1541,6 +1547,10 @@ void ItemList::_get_property_list(List<PropertyInfo> *p_list) const {
pi.usage &= ~(get_item_icon(i).is_null() ? PROPERTY_USAGE_STORAGE : 0);
p_list->push_back(pi);
+ pi = PropertyInfo(Variant::BOOL, vformat("item_%d/selectable", i));
+ pi.usage &= ~(is_item_selectable(i) ? PROPERTY_USAGE_STORAGE : 0);
+ p_list->push_back(pi);
+
pi = PropertyInfo(Variant::BOOL, vformat("item_%d/disabled", i));
pi.usage &= ~(!is_item_disabled(i) ? PROPERTY_USAGE_STORAGE : 0);
p_list->push_back(pi);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index e688ba9826..77e910870f 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -62,7 +62,7 @@ private:
String language;
TextDirection text_direction = TEXT_DIRECTION_AUTO;
- bool selectable = false;
+ bool selectable = true;
bool selected = false;
bool disabled = false;
bool tooltip_enabled = true;