diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index 844ad29ef..33f01a452 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -420,3 +420,7 @@ layout_mode = 2 [connection signal="mouse_entered" from="DockableContainer/Main Canvas/HorizontalRuler" to="DockableContainer/Main Canvas/HorizontalRuler" method="_on_HorizontalRuler_mouse_entered"] [connection signal="pressed" from="DockableContainer/Main Canvas/HorizontalRuler" to="DockableContainer/Main Canvas/HorizontalRuler" method="_on_HorizontalRuler_pressed"] [connection signal="pressed" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/VerticalRuler" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/VerticalRuler" method="_on_VerticalRuler_pressed"] +[connection signal="mouse_entered" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" method="_on_ViewportContainer_mouse_entered"] +[connection signal="mouse_exited" from="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" to="DockableContainer/Main Canvas/ViewportandVerticalRuler/SubViewportContainer" method="_on_ViewportContainer_mouse_exited"] +[connection signal="mouse_entered" from="DockableContainer/Second Canvas" to="DockableContainer/Second Canvas" method="_on_ViewportContainer_mouse_entered"] +[connection signal="mouse_exited" from="DockableContainer/Second Canvas" to="DockableContainer/Second Canvas" method="_on_ViewportContainer_mouse_exited"] diff --git a/src/UI/ViewportContainer.gd b/src/UI/ViewportContainer.gd index 603a078fb..e0966199b 100644 --- a/src/UI/ViewportContainer.gd +++ b/src/UI/ViewportContainer.gd @@ -2,8 +2,6 @@ extends SubViewportContainer @export var camera_path: NodePath -var _mouse_inside = false - @onready var camera := get_node(camera_path) as CanvasCamera @@ -12,20 +10,17 @@ func _ready() -> void: material.blend_mode = CanvasItemMaterial.BLEND_MODE_PREMULT_ALPHA -func _input(event): - if event is InputEventMouseMotion: - if get_global_rect().has_point(event.position): - if !_mouse_inside: - _mouse_inside = true - camera.set_process_input(true) - Global.control.left_cursor.visible = Global.show_left_tool_icon - Global.control.right_cursor.visible = Global.show_right_tool_icon - if Global.cross_cursor: - Input.set_default_cursor_shape(Input.CURSOR_CROSS) - else: - if _mouse_inside: - _mouse_inside = false - camera.drag = false - Global.control.left_cursor.visible = false - Global.control.right_cursor.visible = false - Input.set_default_cursor_shape(Input.CURSOR_ARROW) +func _on_ViewportContainer_mouse_entered() -> void: + camera.set_process_input(true) + Global.control.left_cursor.visible = Global.show_left_tool_icon + Global.control.right_cursor.visible = Global.show_right_tool_icon + if Global.cross_cursor: + Input.set_default_cursor_shape(Input.CURSOR_CROSS) + + +func _on_ViewportContainer_mouse_exited() -> void: + camera.set_process_input(false) + camera.drag = false + Global.control.left_cursor.visible = false + Global.control.right_cursor.visible = false + Input.set_default_cursor_shape(Input.CURSOR_ARROW)