On second NESTED call of native.showAlert no callbacks called, and the first one stay on screen
After selecting button in FIRST alert callback from SECOND called
Demo attached
Steps to reproduce:
Run attached test at emulator and press button
DO NOT close first alert and wait for second
Select any button
You`ll get:
First called
Second called
OnFirstAlert: cancelled
OnSecondAlert: clicked
at console and in text widget
Run this test under Android with same actions.
The first alert stay on screen but callback from second Alert will be called after press a button in a first alert
Output will be:
First called
Second called
OnSecondAlert: clicked
Workaround is to cancel last alert and use timer.performWithDelay to show next:
local LastAlert function AlertClose() if LastAlert then native.cancelAlert(LastAlert) LastAlert = nil end end function Alert( title, text, btns, cb ) AlertClose() timer.performWithDelay( 0, function() LastAlert = native.showAlert(title,text,btns,cb) end ) end function AskYesNo( title, text, cb ) Alert( title,text,{"YES","NO"}, function(event) if event.action == "clicked" and event.index == 1 then cb(event) end end ) end function AlertMessage( title, text, cb ) Alert( title,text,{"OK"}, function(event) cb(event) end ) end