Skip to content

Commit ac4c748

Browse files
dbnicholsondylanmccall
authored andcommitted
Block: Allow to grab focus
Set the focus mode on Blocks so they can process input events. When dragged on the canvas, set the dropped block to be focused. Note the subtle interaction between FocusMode.FOCUS_ALL, which allows focusing by mouse click, and MouseFilter.MOUSE_FILTER_IGNORE, which filters out mouse click events. The combination means that the mouse click will be handled in Godot for focusing the block, but the mouse click can't be processed in _gui_input().
1 parent 8b85fa3 commit ac4c748

File tree

6 files changed

+7
-2
lines changed

6 files changed

+7
-2
lines changed

addons/block_code/drag_manager/drag_manager.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func drag_ended():
7979

8080
if block:
8181
connect_block_canvas_signals(block)
82+
block.grab_focus()
8283

8384
_block_canvas.release_scope()
8485

addons/block_code/ui/blocks/block/block.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func _set_bottom_snap_path(value: NodePath):
4747
func _ready():
4848
if bottom_snap == null:
4949
_set_bottom_snap_path(bottom_snap_path)
50+
focus_mode = FocusMode.FOCUS_ALL
5051
mouse_filter = Control.MOUSE_FILTER_IGNORE
5152

5253

addons/block_code/ui/blocks/control_block/control_block.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
[node name="ControlBlock" type="MarginContainer"]
77
size_flags_horizontal = 0
8+
focus_mode = 2
89
mouse_filter = 2
910
script = ExtResource("1_2hbir")
1011
block_name = "control_block"

addons/block_code/ui/blocks/entry_block/entry_block.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[ext_resource type="Script" path="res://addons/block_code/ui/blocks/entry_block/entry_block.gd" id="2_3ik8h"]
55

66
[node name="EntryBlock" instance=ExtResource("1_byjbb")]
7+
focus_mode = 2
78
script = ExtResource("2_3ik8h")
89
signal_name = ""
9-
defaults = {}
1010
block_name = "entry_block"
1111
label = "EntryBlock"
1212
block_type = 1

addons/block_code/ui/blocks/parameter_block/parameter_block.tscn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ corner_radius_bottom_left = 16
1818
offset_right = 16.0
1919
offset_bottom = 8.0
2020
size_flags_horizontal = 0
21+
focus_mode = 2
22+
mouse_filter = 2
2123
script = ExtResource("1_0hajy")
22-
defaults = null
2324
block_name = "parameter_block"
2425
label = "Param"
2526
block_type = 3

addons/block_code/ui/blocks/statement_block/statement_block.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
[node name="StatementBlock" type="MarginContainer"]
99
size_flags_horizontal = 0
10+
focus_mode = 2
1011
mouse_filter = 2
1112
script = ExtResource("1_6wvlf")
1213
block_name = "statement_block"

0 commit comments

Comments
 (0)