diff --git a/addons/block_code/drag_manager/drag_manager.gd b/addons/block_code/drag_manager/drag_manager.gd index 851520ad..24556c29 100644 --- a/addons/block_code/drag_manager/drag_manager.gd +++ b/addons/block_code/drag_manager/drag_manager.gd @@ -122,6 +122,9 @@ func drag_block(block: Block, copied_from: Block = null): drag_offset = get_local_mouse_position() - block.position dragging = block + if block.scope != "": + _block_canvas.set_scope(block.scope) + func copy_block(block: Block) -> Block: return block.duplicate(DUPLICATE_USE_INSTANTIATION) # use instantiation @@ -163,6 +166,8 @@ func drag_ended(): else: dragging.queue_free() + _block_canvas.release_scope() + dragging = null block_dropped.emit() diff --git a/addons/block_code/ui/block_canvas/block_canvas.gd b/addons/block_code/ui/block_canvas/block_canvas.gd index c37667cc..2e0bcca2 100644 --- a/addons/block_code/ui/block_canvas/block_canvas.gd +++ b/addons/block_code/ui/block_canvas/block_canvas.gd @@ -115,3 +115,20 @@ func find_snaps(node: Node) -> Array: snaps.append_array(find_snaps(c)) return snaps + + +func set_scope(scope: String): + for block in _window.get_children(): + if block is EntryBlock: + var entry_block = block as EntryBlock + + if scope != entry_block.get_entry_statement(): + entry_block.modulate = Color(0.5, 0.5, 0.5, 1) + + +func release_scope(): + for block in _window.get_children(): + if block is EntryBlock: + var entry_block = block as EntryBlock + + entry_block.modulate = Color.WHITE