From aa4a4b07d828fbb0911de87ad3ac4c337193ec0d Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Thu, 28 Aug 2014 22:22:50 -0700 Subject: [PATCH] Fixed: method viewWillMoveToWindow and viewDidMoveToWindow not called when when adding a view to a view without a window where the previous superview had a window --- AppKit/CPView.j | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 90f3cd529..785a420e5 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -514,7 +514,8 @@ var CPViewFlags = { }, [aSubview viewWillMoveToSuperview:self]; // We will have to adjust the z-index of all views starting at this index. - var count = _subviews.length; + var count = _subviews.length, + lastWindow; // Dirty the key view loop, in case the window wants to auto recalculate it [[self window] _dirtyKeyViewLoop]; @@ -544,12 +545,11 @@ var CPViewFlags = { }, { var superview = aSubview._superview; + lastWindow = [superview window]; + // Remove the view from its previous superview. [aSubview _removeFromSuperview]; - if (superview) - [aSubview _setWindow:nil]; - // Set ourselves as the superview. aSubview._superview = self; } @@ -587,6 +587,9 @@ var CPViewFlags = { }, if (_window) [aSubview _setWindow:_window]; + if (!_window && lastWindow) + [aSubview _setWindow:nil]; + // This method might be called before we are fully unarchived, in which case the theme state isn't set up yet // and none of the below matters anyhow. if (_themeState)