If I had a hundred buttons...

Lets say I had a hundred buttons, and the composer sends each one to a different scene,

local function mytouchlisten1 (event)
    composer.gotoScene( “view1” )
end
 

Im assuming I dont have to write a hundred functions that go to a hundred different ‘pages’ or scenes, do I? Im not seeing how I could go about that, so if you some suggestions let me know!

Hi @Beltic,

This is very simple. All you need to do is assign an “id” to each button. If you’re using widget buttons, this is allowed as the “id” parameter of the creator function. If you’re using your own buttons, just assign it as “.id” to the object. Then, in your listener function (just one, not a hundred of them), access “event.target.id” and that will be the id you assigned it. So, just use that have Composer send you to the proper scene.

Brent

Great! Thank you.

Hi @Beltic,

This is very simple. All you need to do is assign an “id” to each button. If you’re using widget buttons, this is allowed as the “id” parameter of the creator function. If you’re using your own buttons, just assign it as “.id” to the object. Then, in your listener function (just one, not a hundred of them), access “event.target.id” and that will be the id you assigned it. So, just use that have Composer send you to the proper scene.

Brent

Great! Thank you.