From 3f9f926c8eecf7efd8e142180affb973e1192cb5 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 2 Jul 2015 13:41:37 -0700 Subject: [PATCH] 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. --- AppKit/Platform/DOM/CPPlatform.j | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AppKit/Platform/DOM/CPPlatform.j b/AppKit/Platform/DOM/CPPlatform.j index 9b287120d..a80f9b0e3 100644 --- a/AppKit/Platform/DOM/CPPlatform.j +++ b/AppKit/Platform/DOM/CPPlatform.j @@ -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