diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 933e03c90..c14103df9 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -791,6 +791,10 @@ CPTexturedBackgroundWindowMask - (void)setFrameOrigin:(CGPoint)anOrigin { [self _setClippedFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO]; + + // reposition sheet + if ([self attachedSheet]) + [self _setAttachedSheetFrameOrigin]; } /*! @@ -1469,6 +1473,25 @@ CPTexturedBackgroundWindowMask var type = [anEvent type], point = [anEvent locationInWindow]; + // If a sheet is attached events get filtered here. + // It is not clear what events should be passed to the view, perhaps all? + // CPLeftMouseDown is needed for window moving and resizing to work. + // CPMouseMoved is needed for rollover effects on title bar buttons. + if ([self attachedSheet]) + { + switch (type) + { + case CPLeftMouseDown: + [_windowView mouseDown:anEvent]; + break; + case CPMouseMoved: + [_windowView mouseMoved:anEvent]; + break; + } + + return; + } + switch (type) { case CPFlagsChanged: return [[self firstResponder] flagsChanged:anEvent]; @@ -2245,7 +2268,9 @@ CPTexturedBackgroundWindowMask endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height); [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self]; - [CPApp runModalForWindow:aSheet]; + + // old behavior; in Cocoa, sheets are not modal by default + //[CPApp runModalForWindow:aSheet]; [aSheet orderFront:self]; [aSheet setFrame:startFrame display:YES animate:NO]; diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index 6a9f62894..e7936dd5a 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -140,7 +140,7 @@ var _CPWindowViewResizeIndicatorImage = nil; var newSize = CGSizeMake(CGRectGetWidth(_resizeFrame) + location.x - CGRectGetMinX(_resizeFrame), CGRectGetHeight(_resizeFrame) + location.y - CGRectGetMinY(_resizeFrame)); if (theWindow._isSheet && theWindow._parentView && (theWindow._frame.size.width !== newSize.width)) - [theWindow._parentView _setAttachedSheetFrameOrigin]; + [theWindow._parentView _setAttachedSheetFrameOrigin]; [theWindow setFrameSize:newSize]; } @@ -195,7 +195,6 @@ var _CPWindowViewResizeIndicatorImage = nil; location = [theWindow convertBaseToGlobal:[anEvent locationInWindow]], origin = [self _pointWithinScreenFrame:CGPointMake(_CGRectGetMinX(frame) + (location.x - _mouseDraggedPoint.x), _CGRectGetMinY(frame) + (location.y - _mouseDraggedPoint.y))]; - [theWindow setFrameOrigin:origin]; _mouseDraggedPoint = [self _pointWithinScreenFrame:location]; @@ -204,6 +203,17 @@ var _CPWindowViewResizeIndicatorImage = nil; [CPApp setTarget:self selector:@selector(trackMoveWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES]; } +- (void)setFrameSize:(CGSize)newSize +{ + [super setFrameSize:newSize]; + + // reposition sheet if the parent window resizes or moves + var theWindow = [self window]; + + if ([theWindow attachedSheet]) + [theWindow _setAttachedSheetFrameOrigin]; +} + - (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator { if (shouldShowResizeIndicator)