fixing error handling when focus list is empty

This commit is contained in:
betalars 2023-07-08 22:06:06 +02:00
parent c31778b314
commit 2ae327339b
1 changed files with 4 additions and 3 deletions

View File

@ -53,10 +53,11 @@ func pass_focus_to(target:Object) -> bool:
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.size() > 0:
if focus_list.front() == target: if focus_list.front() == target:
push_warning(target, " is already target. Abort passing focus.") 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.size() == 0: focus_list.front().has_focus = false
target.has_focus = true target.has_focus = true
if target.has_focus: if target.has_focus:
focus_list.push_front(target) focus_list.push_front(target)