Destroy Soda(Spec) Button

Hi,

How can I destroy a Soda generated Button? Scenario: Instantiate one Button - if pressed switch to new tab show new button and destroy first …

I want to use SodaSpec with the multitab template : https://gist.github.com/dermotbalson/6508514

Kind regards
Sven

@ein_STein I’ve never used Soda so I’m not sure exactly how it’s used. But under normal circumstances to destroy something that’s been instantiated, you just set the variable that’s instantiated to nil.

PS. After the variable is set to nil, you have to make sure any code referencing that variable isn’t used anymore.

@ein_STein I wrote SodaSpec and I’d be glad to help in any way I can.

Since SodaSpecs don’t control UI elements, they just generate them, there’s no way to destroy an element from the spec that made it. You have to use the element itself.

Setting the variable to nil will not work, because SODA maintains its own private references to every UI element, and using nil only destroys something when there are no other references left.

Off the top of my head I forget the exact parameter name, but SODA elements have a flag called something like “kill”, which when set to “true” makes them destroy themselves. It’s simple and easy. You can find the exact term by searching in the SODA project.

Hi all!

This is really a great community! Thank you for the quick response!

Kill was the solution: in the Button pressed callback function I just set touch.kill = true and the Button is gone :slight_smile:

And thank you UberGoober for the fantastic SodaSpec - it makes Soda much more easy to use.