From 0f43cdee00b2aa1c50b56daec0f5daad2307a5dd Mon Sep 17 00:00:00 2001 From: Darrell Walisser Date: Wed, 25 Apr 2012 21:04:38 -0400 Subject: [PATCH] -sheet attached to modal window runs in modal context -events in modal run loop get passed to sheet's parent window, so it can move and resize --- AppKit/CPApplication.j | 4 +++- AppKit/CPWindow/CPWindow.j | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) 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); }