From 2d6dabc68ed6f49e7055d4be3fa7e06e829b3ae5 Mon Sep 17 00:00:00 2001 From: volzhs Date: Sat, 12 Nov 2016 22:43:31 +0900 Subject: [PATCH] Prevent to select children if selection lock or instanced scene Fix #7086 (cherry picked from commit c3f4d676c0e3e02c33bd3aad4fb5b42c20201e7c) --- .../plugins/canvas_item_editor_plugin.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index d76dd983171..5f2841f031d 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -522,17 +522,24 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2& p_rect,Node* p_no CanvasItem *c=p_node->cast_to(); - for (int i=p_node->get_child_count()-1;i>=0;i--) { + bool inherited=p_node!=get_tree()->get_edited_scene_root() && p_node->get_filename()!=""; + bool editable=false; + if (inherited){ + editable=EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(p_node); + } + bool lock_children=p_node->has_meta("_edit_group_") && p_node->get_meta("_edit_group_"); + if (!lock_children && (!inherited || editable)) { + for (int i=p_node->get_child_count()-1;i>=0;i--) { - if (c && !c->is_set_as_toplevel()) - _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items); - else { - CanvasLayer *cl = p_node->cast_to(); - _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items); + if (c && !c->is_set_as_toplevel()) + _find_canvas_items_at_rect(p_rect,p_node->get_child(i),p_parent_xform * c->get_transform(),p_canvas_xform,r_items); + else { + CanvasLayer *cl = p_node->cast_to(); + _find_canvas_items_at_rect(p_rect,p_node->get_child(i),transform,cl?cl->get_transform():p_canvas_xform,r_items); + } } } - if (c && c->is_visible() && !c->has_meta("_edit_lock_") && !c->cast_to()) { Rect2 rect = c->get_item_rect();