Merge pull request #2176 from Dogild/CPView-addSubview

Fixed: Methods viewDidMoveToSuperview viewDidMoveToWindow viewWillMoveToSuperview viewWillMoveToWindow not called as in Cocoa
This commit is contained in:
Antoine Mercadal committed 2014-09-24 12:22:07 -07:00
commit 71bfe4dd44
10 files changed
+498 -52

No files matched your search

+20 -2
View File
@@ -473,8 +473,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
if (!_sortDescriptors)
_sortDescriptors = [];
[self _startObservingFirstResponder];
}
/*!
@@ -4456,6 +4454,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[super viewWillMoveToSuperview:aView];
var superview = [self superview],
defaultCenter = [CPNotificationCenter defaultCenter];
@@ -5128,6 +5128,24 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
return hit;
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _stopObservingFirstResponder];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _startObservingFirstResponder];
}
- (void)_startObservingFirstResponder
{
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:[self window]];