From cf5cad7126e846d99f4549fd0b9fe499f27a190c Mon Sep 17 00:00:00 2001 From: jmb462 Date: Fri, 7 Jan 2022 23:26:27 +0100 Subject: [PATCH] Expose selectable property of ItemList's Item --- scene/gui/item_list.cpp | 10 ++++++++++ scene/gui/item_list.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index b0dc12d0467..0cb3249c1d4 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 *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 e688ba98260..77e910870f8 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;