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

This commit is contained in:
Alexandre Wilhelm
2014-08-28 22:22:50 -07:00
parent 1fcf13d149
commit aa4a4b07d8
+7 -4
View File
@@ -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)