diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-11-27 13:04:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 13:04:20 +0100 |
commit | 17b4f43e0e0a16d27bd769cab854e2be5e26833f (patch) | |
tree | 755ed27e9a273c09f2e308778641d01d3af393d9 | |
parent | 6aa331e5812ce48aa30ea08ed1adc598c9e5b4f6 (diff) | |
parent | b8b5bb657767698b5864356fb2549ee9681f1bd6 (diff) |
Merge pull request #13308 from Krakean/scenetreedock_additemsdeselect
Scene Tree Dock: added ability to deselect items when clicking on empty space
-rw-r--r-- | editor/scene_tree_editor.cpp | 8 | ||||
-rw-r--r-- | editor/scene_tree_editor.h | 1 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 4 |
3 files changed, 13 insertions, 0 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index dfda8a780d..2c0981ca30 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -481,6 +481,12 @@ void SceneTreeEditor::_selected_changed() { blocked--; } +void SceneTreeEditor::_deselect_items() { + + // Clear currently elected items in scene tree dock. + editor_selection->clear(); +} + void SceneTreeEditor::_cell_multi_selected(Object *p_object, int p_cell, bool p_selected) { TreeItem *item = Object::cast_to<TreeItem>(p_object); @@ -929,6 +935,7 @@ void SceneTreeEditor::_bind_methods() { ClassDB::bind_method("_update_tree", &SceneTreeEditor::_update_tree); ClassDB::bind_method("_node_removed", &SceneTreeEditor::_node_removed); ClassDB::bind_method("_selected_changed", &SceneTreeEditor::_selected_changed); + ClassDB::bind_method("_deselect_items", &SceneTreeEditor::_deselect_items); ClassDB::bind_method("_renamed", &SceneTreeEditor::_renamed); ClassDB::bind_method("_rename_node", &SceneTreeEditor::_rename_node); ClassDB::bind_method("_test_update_tree", &SceneTreeEditor::_test_update_tree); @@ -1005,6 +1012,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope tree->connect("item_edited", this, "_renamed", varray(), CONNECT_DEFERRED); tree->connect("multi_selected", this, "_cell_multi_selected"); tree->connect("button_pressed", this, "_cell_button_pressed"); + tree->connect("nothing_selected", this, "_deselect_items"); //tree->connect("item_edited", this,"_renamed",Vector<Variant>(),true); error = memnew(AcceptDialog); diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 1114b92796..88d60f9b8a 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -78,6 +78,7 @@ class SceneTreeEditor : public Control { TreeItem *_find(TreeItem *p_node, const NodePath &p_path); void _notification(int p_what); void _selected_changed(); + void _deselect_items(); void _rename_node(ObjectID p_node, const String &p_name); void _cell_collapsed(Object *p_obj); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 9213296c55..57c6737848 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1923,6 +1923,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool c = c->next; item_h += child_h; } + + if (!c && !p_mod->get_shift() && !p_mod->get_control() && !p_mod->get_command() && !click_handled && p_button != BUTTON_RIGHT) + emit_signal("nothing_selected"); } } @@ -3750,6 +3753,7 @@ void Tree::_bind_methods() { ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked"))); ADD_SIGNAL(MethodInfo("item_activated")); ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column"))); + ADD_SIGNAL(MethodInfo("nothing_selected")); BIND_ENUM_CONSTANT(SELECT_SINGLE); BIND_ENUM_CONSTANT(SELECT_ROW); |