diff --git a/ChangeLog b/ChangeLog index 2fffafc67..0ad034143 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-01-26 Adrian Robert + + * Source/NSApplication.m (-beginModalSessionforWindow:): Center + panels only if they are not already up, matching OS X Panther; + document. + (-runModalForWindow:, -runModalSession:): Clarify documentation. + 2005-01-25 01:05 Alexander Malmberg * Source/NSImageCell.m (-drawInteriorWithFrame:inView:): Use diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 6ac6db686..2b561bb82 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -1219,6 +1219,11 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) [NSException raise: NSAbortModalException format: @"abortModal"]; } +/** + * Set up modal session for theWindow, and, if it is not visible already, + * puts it up on screen, centering it if it is an NSPanel. It is then + * ordered front and made key or main window. + */ - (NSModalSession) beginModalSessionForWindow: (NSWindow*)theWindow { NSModalSession theSession; @@ -1232,12 +1237,13 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) _session = theSession; /* - * The NSWindow documentation says runModalForWindow centers panels. - * Here would seem the best place to do it. + * Displaying / raising window but centering panel only if not up + * seems to match the behavior on OS X (Panther). */ if ([theWindow isKindOfClass: [NSPanel class]]) { - [theWindow center]; + if ([theWindow isVisible] == NO) + [theWindow center]; [theWindow setLevel: NSModalPanelWindowLevel]; } [theWindow orderFrontRegardless]; @@ -1294,6 +1300,12 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) NSZoneFree(NSDefaultMallocZone(), theSession); } +/** + * Starts modal event loop for given window, after calling + * -beginModalSessionForWindow:. Loop is broken only by stopModal: , + * -stopModalWithCode: , or -abortModal: , at which time -endModalSession: + * is called. + */ - (int) runModalForWindow: (NSWindow*)theWindow { NSModalSession theSession = 0; @@ -1348,14 +1360,18 @@ static NSSize scaledIconSizeForSize(NSSize imageSize) /**

Processes any events for a modal session described by the theSession -variable. Before processing the events, it makes the session window key -and orders the window front, so there is no need to do this -separately. When finished, it returns the state of the session (i.e. +variable. When finished, it returns the state of the session (i.e. whether it is still running or has been stopped, etc)

If there are no pending events for the session, this method returns immediately.

+

+ Although Apple's docs state that, before processing the events, it makes the + session window key and orders the window front, this method does not attempt + to do this (due to excessive overhead). Therefore you should do it yourself + beforehand, if needed. +

See Also: -runModalForWindow: