So I am having an issue where the function call in the showAlert is not working. I think it might be a scope issue… but i’m not sure?
Basically I have a display object with a touch listener on it:
local function calcTouch( event ) if event.phase == "ended" then local continue = false for i = 1, 5, 1 do if tapTable[i].text == "Tap Me" then continue = true end end if not continue then native.showAlert ("Continue?", "Press OK to reset all values and continue.", { "OK", "Cancel" }, alertListener2 ) else storyboard.showOverlay( "calculator", { effect="fromTop", time=200, params = { negTrue = false, needDec = true }, isModal = true } ) end return true end end
The alert box pops up when it’s supposed to, but the alertListener2 function does not fire off. Pressing the OK or Cancel buttons just closes the box. I have the alertListener2 function directly below the above code:
local function alertListener2 ( event ) if "clicked" == event.action then local i = event.index if 1 == i then print("OK was pressed") elseif 2 == i then print("Cancel was pressed") end end end
Nothing happens, it is def not calling the function.