move _set_keyboard_pressed_position to _on_keyboard_layout_size_changed

This commit is contained in:
Teatov 2025-08-02 11:36:58 +10:00
parent 2863a7fc7d
commit ead41f16d5

View File

@ -111,6 +111,7 @@ func _unhandled_input(event: InputEvent) -> void:
if (
event_key.physical_keycode != props.physical_keycode
or event_key.echo
or (
event_key.location != KEY_LOCATION_UNSPECIFIED
and props.location != KEY_LOCATION_UNSPECIFIED
@ -121,9 +122,6 @@ func _unhandled_input(event: InputEvent) -> void:
_set_pressing_from_event(event_key)
if event_key.echo:
return
if LayoutConfig.is_configuring and event_key.is_pressed():
var new_char_type: KeyProps.Char
if not keyboard.alt_visual_layout:
@ -153,11 +151,8 @@ func _exit_tree() -> void:
#region public
func load_props(_props: KeyProps, init_pos: Vector3, default_angle: float) -> void:
_set_keyboard_pressed_position(false)
_init_position = init_pos
_default_rotation.y = default_angle
if _is_pressed:
_set_keyboard_pressed_position(true)
if props:
_props.chars_from_dict(props.chars_to_dict())
@ -357,10 +352,13 @@ func _play_sfx(stream: AudioStream) -> void:
#region event handlers
func _on_keyboard_layout_size_changed(rect: Rect2) -> void:
_set_keyboard_pressed_position(false)
var center := rect.get_center()
_default_position = _init_position
_default_position.x -= center.x
_default_position.z -= center.y
if _is_pressed:
_set_keyboard_pressed_position(true)
if not _pos_sod:
_reset_animations()