I have an app with five buttons on a main screen. I have created five onTouch functions, one for each button. Here is one example:
– Touch event listener for Settings button
local onSettingsTouch = function( event )
print(“Touch:Settings event=”, event.phase)
if event.phase == “began” then
storyboard.gotoScene( “settings”, “slideLeft”, 800 )
return true
end
end
…
…
buttonSettings = widget.newButton
{
id = “buttonSettings”,
label = “Settings”,
defaultFile = “buttonWhite.png”,
overFile = “buttonWhiteOver.png”,
emboss = true,
isEnabled = true,
onPress = onSettingsTouch,
onRelease = onSettingsTouch,
onEvent = onSettingsTouch,
}
buttonSettings.touch = onSettingsTouch
group:insert(buttonSettings)
…
…
function scene:enterScene( event )
print( "Entry: enterScene event start: ", event )
buttonSettings:addEventListener( “touch”, buttonSettings )
print( "Entry: enterScene event end: ", event )
end
Everything displays correctly, but I never get to the onSettingsTouch function when I click the Settongs button. The print messages from the enterScene function display, but not the one in the onSettingsTouch function. I tried linking the onSettingsTouch function to my background display object and it worked fine.
So how do I get the button to connect to the onSettingsTouch function? I know I am missing something obvious, but what?
Thanks!!