How To Properly Remove A Button 2.0

My main doubt is how to deal with the event listener, i have the following code to create the button:

boton widget.newButton{
        id = “btn001”,
        left = 370,
        top = 170,
        label = “Aceptar”,
        width = 100, height = 50,
        cornerRadius = 0,
        onEvent = irAMenu
    }

when I dont need it anymore i just call boton:removeSelf() and boton = nil ???

What happens with onEvent event?? Wouldnt it become a memory leak? Thanks in advance

My main doubt is how to deal with the event listener, i have the following code to create the button:

boton widget.newButton{
        id = “btn001”,
        left = 370,
        top = 170,
        label = “Aceptar”,
        width = 100, height = 50,
        cornerRadius = 0,
        onEvent = irAMenu
    }

when I dont need it anymore i just call boton:removeSelf() and boton = nil ???

What happens with onEvent event?? Wouldnt it become a memory leak? Thanks in advance

All you need to do is removeSelf and nil the button. When the object no longer exists, neither does it’s touch listener.

Thanks

Thanks for the reply!

My main doubt is how to deal with the event listener, i have the following code to create the button:

boton widget.newButton{
        id = “btn001”,
        left = 370,
        top = 170,
        label = “Aceptar”,
        width = 100, height = 50,
        cornerRadius = 0,
        onEvent = irAMenu
    }

when I dont need it anymore i just call boton:removeSelf() and boton = nil ???

What happens with onEvent event?? Wouldnt it become a memory leak? Thanks in advance

All you need to do is removeSelf and nil the button. When the object no longer exists, neither does it’s touch listener.

Thanks

Thanks for the reply!