From b60c4b05d53018a9b003efcb0a82b56d4ca5db30 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Tue, 1 Sep 2020 21:37:13 +0200 Subject: [PATCH] Insert a node's ID on click --- node.gd | 8 ++++++++ node.tscn | 1 + 2 files changed, 9 insertions(+) diff --git a/node.gd b/node.gd index cea8618..6e97f85 100644 --- a/node.gd +++ b/node.gd @@ -35,6 +35,9 @@ func type_set(new_type): type = new_type if type != "ref": $ID.text = $ID.text.substr(0,8) + elif type == "ref": + var parts = $ID.text.split("/") + $ID.text = parts[parts.size()-1] match new_type: "blob": $Rect.color = Color("#333333") @@ -76,3 +79,8 @@ func _on_unhover(): $Content.visible = false $ID.visible = false +func _input_event(viewport, event, shape_idx): + if event is InputEventMouseButton and event.pressed: + var input = get_tree().get_current_scene().find_node("Terminal").find_node("Control").find_node("Input") + input.text += $ID.text + input.caret_position = input.text.length() diff --git a/node.tscn b/node.tscn index 7e40245..b710c6d 100644 --- a/node.tscn +++ b/node.tscn @@ -53,5 +53,6 @@ __meta__ = { shape = SubResource( 1 ) [node name="Arrows" type="Node2D" parent="."] +[connection signal="input_event" from="Area" to="." method="_input_event"] [connection signal="mouse_entered" from="Area" to="." method="_on_hover"] [connection signal="mouse_exited" from="Area" to="." method="_on_unhover"]