diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-08 08:35:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-08 08:35:04 +0200 |
commit | 3bfffcc568d87342e867f95c35a4a19e09072189 (patch) | |
tree | 2afacc90f5cb33793e7adea8132e37bc975d7d08 | |
parent | 74b00d1beafb31e8cf3ca4f7bf35118232662d45 (diff) | |
parent | fe9ec58028ff5f89aa1db1d4faa1ec7af00b6c3d (diff) |
Merge pull request #30408 from Meriipu/tree_buttondisable
TreeItem: Added a setter for the disabled-property of buttons
-rw-r--r-- | scene/gui/tree.cpp | 8 | ||||
-rw-r--r-- | scene/gui/tree.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index c2493ab321..8624baa005 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -571,7 +571,14 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } +void TreeItem::set_disable_button(int p_column, int p_idx, bool p_disabled) { + ERR_FAIL_INDEX(p_column, cells.size()); + ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size()); + + cells.write[p_column].buttons.write[p_idx].disabled = p_disabled; + _changed_notify(p_column); +} bool TreeItem::is_button_disabled(int p_column, int p_idx) const { ERR_FAIL_INDEX_V(p_column, cells.size(), false); @@ -786,6 +793,7 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button); ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); ClassDB::bind_method(D_METHOD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled); + ClassDB::bind_method(D_METHOD("set_disable_button", "column", "button_idx", "disabled"), &TreeItem::set_disable_button); ClassDB::bind_method(D_METHOD("set_expand_right", "column", "enable"), &TreeItem::set_expand_right); ClassDB::bind_method(D_METHOD("get_expand_right", "column"), &TreeItem::get_expand_right); diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 45d451eb72..6e5e2c1eba 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -212,6 +212,7 @@ public: bool is_button_disabled(int p_column, int p_idx) const; void set_button(int p_column, int p_idx, const Ref<Texture> &p_button); void set_button_color(int p_column, int p_idx, const Color &p_color); + void set_disable_button(int p_column, int p_idx, bool p_disabled); /* range works for mode number or mode combo */ |