34 lines
779 B
GDScript3
Raw Normal View History

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