[code] – Touch function
local function touchButton(event)
print(“Button pressed!”)
end
– Button function
function labelButton(params)
– Imagine various doses of display.newImage and display.newText
end
– Generate the button
local myAwesomeButton = labelButton{ x=200,y=200 }
[/code]
Given that snazzy code, I have to admit I’ve run adrift on finding the best way to make the button clickable.
At first I tried… [lua]myAwesomeButton:addEventListener(“touch”, touchButton)[/lua]… but Corona choked on adding a listener to a function instead of an image. So I guess I’m approaching this the wrong way.
So I have to ask:
When making buttons, do you plant Runtime:addEventListener inside the creation function, or do you do something outside? (I see some functions people use with subfunctions like myAwesomeButton:touch()?) [import]uid: 41884 topic_id: 14875 reply_id: 314875[/import]
