So I have this code to set up my UI buttons (there is a bit more code before this to set up the UI):
@editable Button2_Text : string = ""
@editable Button2_Position : vector2 = vector2{}
@editable Button2_Size : vector2 = vector2{}
EnableMsg<localizes>():message="ENABLE"
DisableMsg<localizes>():message="DISABLE"
MakeCanvas(Agent:agent):canvas=
Button2 : button_loud = button_loud{}
Button2.SetText(StringToMsg(Button2_Text))
Button2.OnClick().Subscribe(HandleButton2)
var MyCanvas : canvas = canvas:
Slots:= array:
canvas_slot:
Widget:=Button2
ZOrder:=4
SizeToContent:=true
Offsets:=margin{Top:=Button2_Position.Y, Left:=Button2_Position.X, Bottom:=Button2_Size.Y, Right:=Button2_Size.X}
return MyCanvas
and so once Button2 is clicked (HandleButton2) I want its text to change to “DISABLE”, so assign DisableMsg() to it. Then if it’s clicked again assign the “ENABLE” text to it. When I try to refer to Button2 in HandleButton2 it throws an unknown identifier error, so how could this be done?