diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 98f9ade68f..3e6d211961 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -40,6 +40,7 @@
Clears the tree. This removes all items.
+ Prints an error and does not allow clearing the tree if called during mouse selection.
@@ -50,6 +51,7 @@
Creates an item in the tree and adds it as a child of [param parent], which can be either a valid [TreeItem] or [code]null[/code].
If [param parent] is [code]null[/code], the root item will be the parent, or the new item will be the root itself if the tree is empty.
The new item will be the [param index]-th child of parent, or it will be the last child if there are not enough siblings.
+ Prints an error and returns [code]null[/code] if called during mouse selection, or if the [param parent] does not belong to this tree.
@@ -350,6 +352,7 @@
The number of columns.
+ Prints an error and does not allow setting the columns during mouse selection.
The drop mode as an OR combination of flags. See [enum DropModeFlags] constants. Once dropping is done, reverts to [constant DROP_MODE_DISABLED]. Setting this during [method Control._can_drop_data] is recommended.
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index b641b81123..542e9eaf79 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -5136,7 +5136,7 @@ Size2 Tree::get_minimum_size() const {
}
TreeItem *Tree::create_item(TreeItem *p_parent, int p_index) {
- ERR_FAIL_COND_V(blocked > 0, nullptr);
+ ERR_FAIL_COND_V_MSG(blocked > 0, nullptr, "The tree cannot create items during mouse selection events.");
TreeItem *ti = nullptr;
@@ -5291,7 +5291,7 @@ bool Tree::is_anything_selected() {
}
void Tree::clear() {
- ERR_FAIL_COND(blocked > 0);
+ ERR_FAIL_COND_MSG(blocked > 0, "The tree cannot be cleared during mouse selection events.");
if (pressing_for_editor) {
if (range_drag_enabled) {
@@ -5568,7 +5568,7 @@ void Tree::propagate_set_columns(TreeItem *p_item) {
void Tree::set_columns(int p_columns) {
ERR_FAIL_COND(p_columns < 1);
- ERR_FAIL_COND(blocked > 0);
+ ERR_FAIL_COND_MSG(blocked > 0, "The number of columns cannot be changed during mouse selection events.");
if (columns.size() > p_columns) {
for (int i = p_columns; i < columns.size(); i++) {