Added UI focus tracking
This commit is contained in:
@ -2,26 +2,27 @@ 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):
|
||||
if Global.interacting_with_ui:
|
||||
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():
|
||||
func on_focus_entered():
|
||||
var tween := get_tree().create_tween()
|
||||
tween.tween_property(self, "modulate", Color(1, 1, 1, 1), 0.2)
|
||||
Global.interacting_with_ui = true
|
||||
|
||||
func _on_focus_exited():
|
||||
func on_focus_exited():
|
||||
var tween := get_tree().create_tween()
|
||||
tween.tween_property(self, "modulate", Color(1, 1, 1, 0), 0.2)
|
||||
Global.interacting_with_ui = false
|
||||
|
||||
func _on_text_submitted(message: String):
|
||||
(owner as UIManager).chat_message_submitted.emit(message)
|
||||
func on_text_submitted(message: String):
|
||||
(owner as UI).chat_message_submitted.emit(message)
|
||||
text = ""
|
||||
release_focus()
|
||||
|
Reference in New Issue
Block a user