material-maker/addons/material_maker/widgets/linked_widgets/editable_label.gd
Hugo Locurcio 93c84650cd
Add return type hints to all scripts
This also simplifies some functions.

This partially addresses #30.
2019-10-20 16:35:45 +02:00

30 lines
656 B
GDScript

tool
extends HBoxContainer
var text setget set_text, get_text
signal label_changed(new_label)
func get_text() -> String:
return $Label.text
func set_text(t) -> void:
$Label.text = t
func _on_gui_input(ev) -> void:
if ev is InputEventMouseButton and ev.pressed and ev.button_index == BUTTON_LEFT:
$Label.visible = false
$Editor.text = $Label.text
$Editor.visible = true
$Editor.select()
$Editor.grab_focus()
func _on_Editor_text_entered(__) -> void:
_on_Editor_focus_exited()
func _on_Editor_focus_exited() -> void:
$Label.text = $Editor.text
$Label.visible = true
$Editor.visible = false
emit_signal("label_changed", $Editor.text)