私は Gideros で Lua を使用しており、戻るボタンが押されたときにアラート ボックスが表示されるようにしています。私のAndroid phone.printステートメントを使用しようとしても実行されなかったので、oncomplete関数がまったく呼び出されていないことに気付きました。なぜ呼び出されないのですか?
local function onKeyDown(event)
if event.keyCode == KeyCode.BACK then
local alertDialog = AlertDialog.new("Confirmation", "Are you sure you want to exit?", "Cancel", "Yes")
alertDialog:show()
stage:addEventListener(Event.COMPLETE, oncomplete)
end
end
function oncomplete(e)
if e.buttonIndex == 1 then
stage:addEventListener(Event.APPLICATION_SUSPEND, suspend)
application: exit()
end
end
function suspend()
application: exit()
end
-- key events are dispatched to all Sprite instances on the scene tree (similar to mouse and touch events)
stage:addEventListener(Event.KEY_DOWN, onKeyDown)