diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 64c49d71f..a652f6915 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -933,6 +933,19 @@ CPRunContinuesResponse = -1002; return; } + if ([aWindow attachedSheet]) + { + [CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: already has a sheet"]; + return; + } + + if ([aWindow isSheet]) + { + [CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: cannot be a sheet"]; + return; + } + + [aWindow orderFront:self]; [aSheet setPlatformWindow:[aWindow platformWindow]]; [aWindow _attachSheet:aSheet modalDelegate:aModalDelegate didEndSelector:aDidEndSelector contextInfo:aContextInfo]; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index d10a203d7..e0c10d082 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -1224,6 +1224,8 @@ CPTexturedBackgroundWindowMask [defaultCenter removeObserver:_delegate name:CPWindowDidResignMainNotification object:self]; [defaultCenter removeObserver:_delegate name:CPWindowDidMoveNotification object:self]; [defaultCenter removeObserver:_delegate name:CPWindowDidResizeNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowWillBeginSheetNotification object:self]; + [defaultCenter removeObserver:_delegate name:CPWindowDidEndSheetNotification object:self]; _delegate = aDelegate; _delegateRespondsToWindowWillReturnUndoManagerSelector = [_delegate respondsToSelector:@selector(windowWillReturnUndoManager:)]; @@ -1269,6 +1271,20 @@ CPTexturedBackgroundWindowMask selector:@selector(windowDidResize:) name:CPWindowDidResizeNotification object:self]; + + if ([_delegate respondsToSelector:@selector(windowWillBeginSheet:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(windowWillBeginSheet:) + name:CPWindowWillBeginSheetNotification + object:self]; + + if ([_delegate respondsToSelector:@selector(windowDidEndSheet:)]) + [defaultCenter + addObserver:_delegate + selector:@selector(windowDidEndSheet:) + name:CPWindowDidEndSheetNotification + object:self]; } /*! @@ -2367,6 +2383,7 @@ CPTexturedBackgroundWindowMask startFrame = CGRectMake(originx, originy, sheetFrame.size.width, 0), endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height); + [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self]; // if sheet is attached to a modal window, the sheet runs