so i’m building a calculator and i don’t want multiple lines of code for the exact same thing. i want to make sure i identify which button is clicked on button click using a single function but i couldn’t find any resource or reference. kindly help me out
extends Sprite2D
var answer = 0
@onready var equation = $Equation
@onready var answerdisplay = $Answer
func _on_all_clear_button_pressed():
equation.text = “”
answerdisplay.text = "= "
func _on_button_1_pressed():
equation.text = equation.text + “1”
func _on_button_2_pressed():
equation.text = equation.text + “2”
func _on_cancel_button_pressed():
equation.text = equation.text.left(-1)
func _on_button_7_pressed():
equation.text = equation.text + “7”
func _on_button_8_pressed():
equation.text = equation.text + “8”
func _on_button_9_pressed():
equation.text = equation.text + “9”
func _on_button_4_pressed():
equation.text = equation.text + “4”
func _on_button_00_pressed():
equation.text = equation.text + “00”
func _on_button_3_pressed():
equation.text = equation.text + “3”
func _on_button_0_pressed():
equation.text = equation.text + “0”
func _on_button_5_pressed():
equation.text = equation.text + “5”
func _on_button_6_pressed():
equation.text = equation.text + “6”
func _on_decimal_button_pressed():
equation.text = equation.text + “.”
func _on_add_button_pressed():
equation.text = equation.text + “+”
func _on_equalsbutton_pressed():
answerdisplay.text = "= " + str(answer)
func _on_divide_pressed():
equation.text = equation.text + “÷”
func _on_percentage_button_pressed():
equation.text = equation.text + “%”
func _on_subtrack_button_pressed():
equation.text = equation.text + “-”
func _on_multiply_button_pressed():
equation.text = equation.text + “*”
func identifywhichbuttonisclicked(): #How can i identify which button activated the function
pass
please let me know what can be done here