Created
January 26, 2013 01:27
-
-
Save MisterPoppet/4639473 to your computer and use it in GitHub Desktop.
This is the bare minimum javascript you need to ensure that a TideSDK-based app will not exit when you close the window on a Mac. It simply reopens the closed the window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var preventCloseEvent = function() { | |
var appWindow = Ti.UI.getCurrentWindow(); | |
appWindow.addEventListener(Ti.CLOSE, function(event) { | |
appWindow.hide(); | |
event.preventDefault(); | |
return false; | |
}); | |
return appWindow; | |
} | |
var os = Ti.Platform.name.toLowerCase() | |
if (os == 'darwin') { | |
var appWindow = preventCloseEvent(); | |
} else { | |
var appWindow = Titanium.UI.getCurrentWindow(); | |
} | |
if (os == 'darwin') { | |
Ti.API.addEventListener("reopen", function (e) { | |
if (!e.hasVisibleWindows) { | |
appWindow.show(); | |
e.preventDefault(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment