diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 1e7a618ae..64c49d71f 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -1181,7 +1181,9 @@ _CPRunModalLoop = function(anEvent) var theWindow = [anEvent window], modalSession = CPApp._currentSession; - if (theWindow == modalSession._window || [theWindow worksWhenModal]) + if (theWindow == modalSession._window || + [theWindow worksWhenModal] || + [theWindow attachedSheet] == modalSession._window) [theWindow sendEvent:anEvent]; } diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 08ee7ec13..d10a203d7 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -2369,8 +2369,14 @@ CPTexturedBackgroundWindowMask [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self]; - // old behavior; in Cocoa, sheets are not modal by default - //[CPApp runModalForWindow:aSheet]; + // if sheet is attached to a modal window, the sheet runs + // as if itself and the parent window are modal + aSheet._isModal = NO; + if ([CPApp modalWindow]===self) + { + [CPApp runModalForWindow:aSheet]; + aSheet._isModal = YES; + } [aSheet orderFront:self]; [aSheet setFrame:startFrame display:YES animate:NO]; @@ -2454,6 +2460,9 @@ CPTexturedBackgroundWindowMask _sheetContext = nil; sheet._parentView = nil; + if (sheet._isModal) + [CPApp stopModal]; + if (delegate != nil && endSelector != nil) objj_msgSend(delegate, endSelector, sheet, returnCode, contextInfo); }