29 lines
724 B
GDScript3
Raw Normal View History

2024-01-28 21:08:08 +00:00
extends LineEdit
2024-02-16 22:45:31 +00:00
func _ready():
modulate.a = 0.0
2024-02-25 18:47:13 +00:00
focus_entered.connect(on_focus_entered)
focus_exited.connect(on_focus_exited)
text_submitted.connect(on_text_submitted)
2024-02-16 22:45:31 +00:00
2024-02-17 12:23:07 +00:00
func _unhandled_key_input(event):
2024-02-25 18:47:13 +00:00
if UI.focus:
2024-01-28 21:08:08 +00:00
return
if event.is_action_pressed("open_chat"):
call_deferred("grab_focus")
2024-01-29 11:32:06 +00:00
get_viewport().set_input_as_handled()
2024-01-28 21:08:08 +00:00
2024-02-25 18:47:13 +00:00
func on_focus_entered():
2024-02-16 22:45:31 +00:00
var tween := get_tree().create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1, 1), 0.2)
2024-01-28 21:08:08 +00:00
2024-02-25 18:47:13 +00:00
func on_focus_exited():
2024-02-16 22:45:31 +00:00
var tween := get_tree().create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.2)
2024-01-28 21:08:08 +00:00
2024-02-25 18:47:13 +00:00
func on_text_submitted(message: String):
2024-01-28 21:08:08 +00:00
text = ""
release_focus()
2024-02-25 22:01:17 +00:00
(owner as Chat).message_submitted.emit(message)