New: added method closeAllPlatformWindows in CPPlatform

Added the method closeAllPlatformWindows in CPPlatform. This platform close all platform windows of the application (except the main one). This method is now used when reloading or leaving a cappuccino application, the application will now close every external window openend by the application.
This commit is contained in:
Alexandre Wilhelm
2015-07-02 13:41:37 -07:00
parent 1f983db47c
commit 3f9f926c8e
+17
View File
@@ -48,10 +48,13 @@ var screenNeedsInitialization = NO,
document.documentElement.style.overflow = "hidden";
if ([CPPlatform isBrowser])
{
window.onunload = function()
{
[self closeAllPlatformWindows];
[CPApp terminate:nil];
};
}
}
+ (BOOL)isBrowser
@@ -138,4 +141,18 @@ var screenNeedsInitialization = NO,
object:self];
}
+ (void)closeAllPlatformWindows
{
var platformWindows = [CPPlatformWindow visiblePlatformWindows],
primaryPlatformWindow = [CPPlatformWindow primaryPlatformWindow],
platformWindowEnumerator = [platformWindows objectEnumerator],
platformWindow = nil;
while ((platformWindow = [platformWindowEnumerator nextObject]) !== nil)
{
if (platformWindow != primaryPlatformWindow)
[platformWindow orderOut:self];
}
}
@end