Skip to content

Commit

Permalink
-sheet attached to modal window runs in modal context
Browse files Browse the repository at this point in the history
-events in modal run loop get passed to sheet's parent window, so it can move and resize
  • Loading branch information
walisser committed Apr 26, 2012
1 parent 06348bb commit 0f43cde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion AppKit/CPApplication.j
Expand Up @@ -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];
}

Expand Down
13 changes: 11 additions & 2 deletions AppKit/CPWindow/CPWindow.j
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 0f43cde

Please sign in to comment.