Question

I was looking for a way to tell the app to confirm if you really want to close the app before losing the changes of the project.

Through the current API, I was not able to do it. Looking on how Air/Flex do that, it looks like an event listener of the window when closing:

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   maxHeight="1080"
                   maxWidth="1920"
                   minWidth="1280"
                   minHeight="720" 
                   showStatusBar="false" 
                   creationComplete="startUp()"
                   closing="closeWindow(event)"
                   >

when I close the window through the Window interface or through the application menu, it executed what I was expecting, a prompt before the window close

Do you want to exit the application?/Do you want to exit without saving changes?
yes no.

Do TideSDK/TideKIT have this behavior? if so, please attach an example. It is very important for me to understand how to do it properly.

Thanks.

Was it helpful?

Solution

This example helped me to do something similar in my TideSDK app: https://gist.github.com/MisterPoppet/4639473

Pulling from the example there you may be able to do something like below to accomplish what you are asking:

var appWindow = Ti.UI.getCurrentWindow();

appWindow.addEventListener(Ti.CLOSE, function(event) {
    var r = confirm("Do you want to exit the application?");
    if (r == true) {
        //close
    } else {
        //cancel close
        event.preventDefault();
        return false;
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top