31 lines
754 B
GDScript
31 lines
754 B
GDScript
extends LineEdit
|
|
|
|
func _ready():
|
|
modulate.a = 0.0
|
|
focus_entered.connect(on_focus_entered)
|
|
focus_exited.connect(on_focus_exited)
|
|
text_submitted.connect(on_text_submitted)
|
|
|
|
func _unhandled_key_input(event: InputEvent):
|
|
if UI.focus:
|
|
return
|
|
|
|
if event.is_action_pressed("open_chat"):
|
|
call_deferred("grab_focus")
|
|
get_viewport().set_input_as_handled()
|
|
|
|
func on_focus_entered():
|
|
var tween := get_tree().create_tween()
|
|
tween.tween_property(self, "modulate", Color(1, 1, 1, 1), 0.2)
|
|
|
|
func on_focus_exited():
|
|
var tween := get_tree().create_tween()
|
|
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.2)
|
|
|
|
func on_text_submitted(message: String):
|
|
text = ""
|
|
release_focus()
|
|
|
|
var chat := owner as Chat
|
|
chat.message_submitted.emit(message)
|