searching siblings to find a node that will take focus
This commit is contained in:
parent
5b41242439
commit
af82bcc9b9
|
|
@ -12,6 +12,11 @@ var allow_skipping: bool = false
|
||||||
var focus_list:Array = []
|
var focus_list:Array = []
|
||||||
var lock_focus: bool = false
|
var lock_focus: bool = false
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
for child in get_parent().get_children():
|
||||||
|
if "has_focus" in child:
|
||||||
|
pass_focus_to(child)
|
||||||
|
|
||||||
# Intented for use when me wants focus for itself, can reclaim focus, thus dropping the stack that focused.
|
# Intented for use when me wants focus for itself, can reclaim focus, thus dropping the stack that focused.
|
||||||
func request_focus_for(me: Object, reclaim: bool = false) -> bool:
|
func request_focus_for(me: Object, reclaim: bool = false) -> bool:
|
||||||
if reclaim:
|
if reclaim:
|
||||||
|
|
@ -47,7 +52,9 @@ func pass_focus_to(target:Object) -> bool:
|
||||||
elif !is_instance_valid(target):
|
elif !is_instance_valid(target):
|
||||||
push_error("Focus instance not valid")
|
push_error("Focus instance not valid")
|
||||||
elif !"has_focus" in target:
|
elif !"has_focus" in target:
|
||||||
push_error(target, " has no has focus method")
|
push_error(target, " has no has focus method.")
|
||||||
|
if focus_list.front() == target:
|
||||||
|
push_warning(target, " is already target. Abort passing focus.")
|
||||||
else:
|
else:
|
||||||
if not focus_list.front() == null: focus_list.front().has_focus = false
|
if not focus_list.front() == null: focus_list.front().has_focus = false
|
||||||
target.has_focus = true
|
target.has_focus = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue