Hello everybody,
I try to find a solution since two days, but i don’t know how i can.
My problem is that in my app, i have :
the view 1 (home menu) and a other view the view 2.
When i’m in the view 2, i put on my code the function which use the back button to come back to the menu.
This function work but, when the app is on the first view (home menu) the function back button continue to work and results the function back button of my view 1.
As if i press the back button TWICE ! I hope that you understand my problem.
back button of my view1 (home) :
local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then os.exit() --- execute la fonction quit qui quitte le jeu elseif 2 == i then storyboard.gotoScene( "view1" ) -- execute la fonction reset c'est à dire rej end end end local function onKeyEvent( event ) local keyName = event.keyName local phase = event.phase if (keyName == "back" and phase == "down") then local alert = native.showAlert( "Bordeaux Privilèges", "Vous souhaitez quitter l'application", { "Quitter", "Annuler" }, onComplete ) return true end return false end Runtime:addEventListener("key", onKeyEvent)
back button on my view 2, to come back to the menu :
local function onKeyEvent( event ) local keyName = event.keyName local phase = event.phase if (keyName == "back" and phase == "up") then storyboard.gotoScene("view1"); return true end return false end Runtime:addEventListener("key", onKeyEvent)