mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
Insert a node's ID on click
This commit is contained in:
parent
ca8aae560c
commit
b60c4b05d5
2 changed files with 9 additions and 0 deletions
8
node.gd
8
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()
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in a new issue