0

私は 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)
4

1 に答える 1

1

会話によると、アラート ボックスを閉じるイベントのイベント リスナーが、アラート ダイアログではなくステージにアタッチされていたことが問題でした。

stage:addEventListener(Event.COMPLETE, oncomplete)

それ以外の

alertDialog:addEventListener(Event.COMPLETE, oncomplete)

于 2014-05-07T20:36:04.670 に答える