Preserve profile name input focus
This commit is contained in:
parent
1f3308d83b
commit
2cb49cf680
2 changed files with 55 additions and 42 deletions
|
|
@ -365,54 +365,60 @@ func _apply_controller_zone_focus() -> void:
|
|||
var control := item as Control
|
||||
if control != null and control not in all_option_controls:
|
||||
all_option_controls.append(control)
|
||||
for control: Control in account_controls + category_controls + all_option_controls:
|
||||
control.focus_mode = Control.FOCUS_NONE
|
||||
var active_controls: Array[Control] = []
|
||||
if _profile_interactive:
|
||||
if _discard_confirmation != null and _discard_confirmation.visible:
|
||||
active_controls = [
|
||||
_confirmation_confirm,
|
||||
_keep_editing_button,
|
||||
]
|
||||
else:
|
||||
match _controller_zone:
|
||||
ControllerZone.ACCOUNT:
|
||||
active_controls = account_controls
|
||||
ControllerZone.CATEGORIES:
|
||||
active_controls = category_controls
|
||||
ControllerZone.OPTIONS:
|
||||
if not option_groups.is_empty():
|
||||
_controller_option_depth = clampi(
|
||||
_controller_option_depth,
|
||||
0,
|
||||
option_groups.size() - 1,
|
||||
)
|
||||
for item: Variant in option_groups[
|
||||
_controller_option_depth
|
||||
]:
|
||||
var control := item as Control
|
||||
if control != null:
|
||||
active_controls.append(control)
|
||||
ControllerZone.COLOR_PICKER:
|
||||
active_controls = _color_picker_controller_controls()
|
||||
var controlled_controls: Array[Control] = (
|
||||
account_controls + category_controls + all_option_controls
|
||||
)
|
||||
for control: Control in [_confirmation_confirm, _keep_editing_button]:
|
||||
if control != null:
|
||||
control.focus_mode = Control.FOCUS_NONE
|
||||
if control != null and control not in controlled_controls:
|
||||
controlled_controls.append(control)
|
||||
for control: Control in controlled_controls:
|
||||
var button := control as BaseButton
|
||||
var requested_focus_mode := (
|
||||
Control.FOCUS_ALL
|
||||
if (
|
||||
control in active_controls
|
||||
and (button == null or not button.disabled)
|
||||
)
|
||||
else Control.FOCUS_NONE
|
||||
)
|
||||
# Reassigning FOCUS_NONE to every control before restoring the active zone
|
||||
# drops an active LineEdit after its first text_changed signal.
|
||||
if control.focus_mode != requested_focus_mode:
|
||||
control.focus_mode = requested_focus_mode
|
||||
if _preview != null:
|
||||
_preview.focus_mode = Control.FOCUS_NONE
|
||||
if _reset_view_button != null:
|
||||
_reset_view_button.focus_mode = Control.FOCUS_NONE
|
||||
if not _profile_interactive:
|
||||
if not _profile_interactive or active_controls.is_empty():
|
||||
return
|
||||
if _discard_confirmation != null and _discard_confirmation.visible:
|
||||
var confirmation_controls: Array[Control] = [
|
||||
_confirmation_confirm,
|
||||
_keep_editing_button,
|
||||
]
|
||||
for control: Control in confirmation_controls:
|
||||
control.focus_mode = Control.FOCUS_ALL
|
||||
ControllerFocusNavigation.configure_spatial_neighbors(
|
||||
confirmation_controls
|
||||
)
|
||||
return
|
||||
var active_controls: Array[Control] = []
|
||||
match _controller_zone:
|
||||
ControllerZone.ACCOUNT:
|
||||
active_controls = account_controls
|
||||
ControllerZone.CATEGORIES:
|
||||
active_controls = category_controls
|
||||
ControllerZone.OPTIONS:
|
||||
if not option_groups.is_empty():
|
||||
_controller_option_depth = clampi(
|
||||
_controller_option_depth,
|
||||
0,
|
||||
option_groups.size() - 1,
|
||||
)
|
||||
for item: Variant in option_groups[_controller_option_depth]:
|
||||
var control := item as Control
|
||||
if control != null:
|
||||
active_controls.append(control)
|
||||
ControllerZone.COLOR_PICKER:
|
||||
active_controls = _color_picker_controller_controls()
|
||||
for control: Control in active_controls:
|
||||
var button := control as BaseButton
|
||||
control.focus_mode = (
|
||||
Control.FOCUS_ALL
|
||||
if button == null or not button.disabled
|
||||
else Control.FOCUS_NONE
|
||||
)
|
||||
ControllerFocusNavigation.configure_spatial_neighbors(active_controls)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue