-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
This commit is contained in:
Darrell Walisser
2012-04-25 21:04:38 -04:00
parent 06348bbe0b
commit 0f43cdee00
2 changed files with 14 additions and 3 deletions
+3 -1
View File
@@ -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];
}
+11 -2
View File
@@ -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);
}