Insert a node's ID on click

This commit is contained in:
Sebastian Morr 2020-09-01 21:37:13 +02:00
parent ca8aae560c
commit b60c4b05d5
2 changed files with 9 additions and 0 deletions

View file

@ -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()

View file

@ -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"]