Skip to content

Commit af807af

Browse files
committed
Reset block size when snap points are changed
Previously, blocks were continuing to occupy space after their children were detached, making it difficult to interact with other blocks in the canvas.
1 parent e4a6bba commit af807af

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.gd

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,13 @@ extends MarginContainer
55
signal mouse_down
66
signal mouse_up
77

8-
var hovered := false
9-
10-
11-
func _on_mouse_entered():
12-
hovered = true
13-
14-
15-
func _on_mouse_exited():
16-
hovered = false
17-
188

199
func _on_gui_input(event):
20-
if hovered:
21-
if event is InputEventMouseButton:
22-
var mouse_event: InputEventMouseButton = event as InputEventMouseButton
23-
if mouse_event.button_index == MOUSE_BUTTON_LEFT and mouse_event.pressed:
24-
mouse_down.emit()
25-
if mouse_event.button_index == MOUSE_BUTTON_LEFT and not mouse_event.pressed:
26-
mouse_up.emit()
10+
if event is InputEventMouseButton and get_global_rect().has_point(event.global_position):
11+
var mouse_event: InputEventMouseButton = event as InputEventMouseButton
12+
if mouse_event.button_index == MOUSE_BUTTON_LEFT and mouse_event.pressed:
13+
mouse_down.emit()
14+
get_viewport().set_input_as_handled()
15+
if mouse_event.button_index == MOUSE_BUTTON_LEFT and not mouse_event.pressed:
16+
mouse_up.emit()
17+
get_viewport().set_input_as_handled()

addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.tscn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ mouse_default_cursor_shape = 2
1212
script = ExtResource("1_5vdxp")
1313

1414
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
15-
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
16-
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]

addons/block_code/ui/blocks/utilities/snap_point/snap_point.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func set_snapped_block(snapped_block: Block) -> Block:
4444

4545
snapped_block_changed.emit(snapped_block)
4646

47+
reset_size()
48+
block.reset_size()
49+
4750
return orphaned_block
4851

4952

0 commit comments

Comments
 (0)