extends TextureButton

@export var button_value = 0
@export var button_texture: Texture2D
@export var button_region: Rect2
@export var audio_player: AudioStreamPlayer2D

@onready var parent: Numpad = get_parent()

func _ready() -> void:
	$Sprite2D.texture = button_texture
	$Sprite2D.region_rect = button_region


func _on_button_down() -> void:
	audio_player.play()
	mouse_default_cursor_shape = Control.CURSOR_DRAG

	if button_value <= 9:
		parent.keypad_entry(button_value)
	elif button_value == 10:
		parent.keypad_backspace()
	else:
		parent.keypad_submit()

func _on_button_release() -> void:
	mouse_default_cursor_shape = Control.CURSOR_ARROW
