2019-10-10 22:43:34 +02:00
|
|
|
extends HBoxContainer
|
|
|
|
|
|
|
|
var text setget set_text, get_text
|
|
|
|
|
|
|
|
signal label_changed(new_label)
|
2018-09-10 08:00:03 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_text() -> String:
|
2019-10-10 22:43:34 +02:00
|
|
|
return $Label.text
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func set_text(t) -> void:
|
2019-10-10 22:43:34 +02:00
|
|
|
$Label.text = t
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_gui_input(ev) -> void:
|
2019-10-10 22:43:34 +02:00
|
|
|
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()
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_Editor_text_entered(__) -> void:
|
2019-10-10 22:43:34 +02:00
|
|
|
_on_Editor_focus_exited()
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _on_Editor_focus_exited() -> void:
|
2019-10-10 22:43:34 +02:00
|
|
|
$Label.text = $Editor.text
|
|
|
|
$Label.visible = true
|
|
|
|
$Editor.visible = false
|
|
|
|
emit_signal("label_changed", $Editor.text)
|