Added UI focus tracking
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
class_name UIManager
|
||||
class_name UI
|
||||
extends Node
|
||||
|
||||
static var focus: Control
|
||||
|
||||
signal chat_message_submitted(message: String)
|
||||
|
||||
@export var login: Signal
|
||||
@ -11,8 +13,18 @@ signal chat_message_submitted(message: String)
|
||||
@export var message_received: Signal
|
||||
|
||||
func _enter_tree():
|
||||
if !get_node_or_null("/root/Main"):
|
||||
connect_fake()
|
||||
if get_node_or_null("/root/Main"):
|
||||
return
|
||||
|
||||
connect_fake()
|
||||
|
||||
func _process(_delta):
|
||||
var new_focus := get_viewport().gui_get_focus_owner()
|
||||
|
||||
if new_focus && new_focus.name != "Unfocus":
|
||||
UI.focus = new_focus
|
||||
else:
|
||||
UI.focus = null
|
||||
|
||||
func connect_fake():
|
||||
for property in get_property_list():
|
||||
@ -21,3 +33,7 @@ func connect_fake():
|
||||
|
||||
add_user_signal(property.name)
|
||||
set(property.name, Signal(self, property.name))
|
||||
|
||||
static func unfocus():
|
||||
if UI.focus:
|
||||
UI.focus.release_focus()
|
Reference in New Issue
Block a user