NSWindowDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.6 and later.
Companion guide
Declared in
NSWindow.h
Related sample code

Overview

The NSWindowDelegate protocol defines the methods that a delegate of NSWindow should implement. All methods in this protocol are optional.

By implementing these methods, the delegate may respond to window resizing, moving, exposing, minimizing, and a number of other window events.

Tasks

Managing Sheets

Sizing Windows

Minimizing Windows

Zooming Window

Managing Full-Screen Presentation

Custom Full-Screen Presentation Animations

Moving Windows

Closing Windows

Managing Key Status

Managing Main Status

Managing Field Editors

Updating Windows

Exposing Windows

Managing Occlusion State

Dragging Windows

Getting the Undo Manager

Managing Titles

Managing Restorable State

Managing Presentation in Version Browsers

Instance Methods

customWindowsToEnterFullScreenForWindow:

Called when the window is about to enter full-screen mode.

- (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window
Parameters
window

The window to enter full-screen mode.

Return Value

An array of windows to use for the animation to full-screen mode for window; otherwise nil.

Discussion

This method lets a window delegate customize the animation when the window is about to enter full-screen mode by providing a custom window or windows containing layers or other effects. If you don’t want to perform custom animation, you can omit the implementation of this method, or it can return nil.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

customWindowsToEnterFullScreenForWindow:onScreen:

Called when the window is about to enter full-screen mode.

- (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window onScreen:(NSScreen *)screen
Parameters
window

The window to enter full-screen mode.

screen

The display screen on which the window will enter full-screen mode.

Return Value

An array of windows to use for the animation to full-screen mode for window; otherwise nil.

Discussion

This method lets a window delegate customize the animation when the window is about to enter full-screen mode by providing a custom window or windows containing layers or other effects. If you don’t want to perform custom animation, you can omit the implementation of this method, or it can return nil.

Special Considerations

If this method and customWindowsToEnterFullScreenForWindow: are both implemented, this method is called.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSWindow.h

customWindowsToExitFullScreenForWindow:

Called when the window is about to exit full-screen mode.

- (NSArray *)customWindowsToExitFullScreenForWindow:(NSWindow *)window
Parameters
window

The window to exit full-screen mode.

Return Value

An array of windows involved in the animation out of full-screen mode for window; otherwise nil.

Discussion

This method lets the window delegate customize the animation when the window is about to exit full-screen mode by providing a custom window or windows containing layers or other effects. If an you do not want to perform custom animation, you can omit the implementation of this method, or it can return nil.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:didDecodeRestorableState:

Tells the delegate the window is has extracted its restorable state from a given archiver.

- (void)window:(NSWindow *)window didDecodeRestorableState:(NSCoder *)state
Parameters
window

The window extracting its restorable state from an archive.

state

The coder extracting the archive.

Discussion

This method is called during the window’s restoreStateWithCoder: method.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:shouldDragDocumentWithEvent:from:withPasteboard:

Asks the delegate whether a user can drag the document icon from the window’s title bar.

- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard
Parameters
window

The window containing the document icon the user wants to drag.

event

The left-mouse down event that triggered the dragging operation.

dragImageLocation

The location of the origin of the document icon, in window coordinates, when the user started the dragging operation.

pasteboard

The pasteboard containing the contents of the document, which the delegate can modify.

Return Value

YES to allow the drag to proceed; NO to prevent it. Before turning no the delegate can implement its own dragging behavior as described below.

Discussion

Implementing this method enables an application to customize the process of dragging the window’s document icon. The delegate can prohibit the drag by returning NO. Before returning NO, the delegate can implement its own dragging behavior using dragImage:at:offset:event:pasteboard:source:slideBack:.

Alternatively, the delegate can enable a drag by returning YES, for example, to override the default NSWindow behavior of prohibiting the drag of an edited document. In addition, the delegate can customize the pasteboard contents before returning YES.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

window:shouldPopUpDocumentPathMenu:

Asks the delegate whether the window displays the title pop-up menu in response to a Command-click or Control-click on its title.

- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
Parameters
window

The window whose title the user Command-clicked or Control-clicked.

menu

The menu the window will display, if allowed. By default, its items are the path components of the file represented by window.

Return Value

YES to allow the display of the title pop-up menu; NO to prevent it.

Availability
  • Available in OS X v10.5 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

window:startCustomAnimationToEnterFullScreenOnScreen:withDuration:

This method is called to start the window animation into full-screen mode, including transitioning to a new space.

- (void)window:(NSWindow *)window startCustomAnimationToEnterFullScreenOnScreen:(NSScreen *)screen withDuration:(NSTimeInterval)duration
Parameters
window

The window to enter full-screen mode.

screen

The display screen on which the window will enter full-screen mode.

duration

The duration of the presentation change.

Discussion

You can implement this method to perform custom animation with the given duration to be in sync with the system animation.

Special Considerations

This method is called only if customWindowsToEnterFullScreenForWindow: returns non-nil. If window:startCustomAnimationToEnterFullScreenWithDuration: and this method are both implemented, this method is called.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSWindow.h

window:startCustomAnimationToEnterFullScreenWithDuration:

This method is called to start the window animation into full-screen mode, including transitioning to a new space.

- (void)window:(NSWindow *)window startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration
Parameters
window

The window to enter full-screen mode.

duration

The duration of the presentation change.

Discussion

You can implement this method to perform custom animation with the given duration to be in sync with the system animation.

Special Considerations

This method is called only if customWindowsToEnterFullScreenForWindow: returns non-nil.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:startCustomAnimationToExitFullScreenWithDuration:

This method is called to start the window animation out of full-screen mode, including transitioning back to the desktop space.

- (void)window:(NSWindow *)window startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration
Parameters
window

The window to exit to full-screen mode.

duration

The duration of the presentation change.

Discussion

You can implement this method to perform custom animation with the given duration to be in sync with the system animation.

Special Considerations

This method is called only if customWindowsToExitFullScreenForWindow: returns non-nil.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:willEncodeRestorableState:

Tells the delegate the window is about to add its restorable state to a given archiver.

- (void)window:(NSWindow *)window willEncodeRestorableState:(NSCoder *)state
Parameters
window

The window adding its restorable state to an archive.

state

The coder creating the archive.

Discussion

This method is called during the window’s encodeRestorableStateWithCoder: method.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:willPositionSheet:usingRect:

Tells the delegate that the window is about to show a sheet at the specified location, giving it the opportunity to return a custom location for the attachment of the sheet to the window.

- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect
Parameters
window

The window containing the sheet to be animated.

sheet

The sheet to be shown.

rect

The default sheet location, just under the title bar of the window, aligned with the left and right edges of the window.

Return Value

The custom location specified.

Discussion

This method is also called whenever the user resizes window while sheet is attached.

This method is useful in many situations. If your window has a toolbar, for example, you can specify a location for the sheet that is just below it. If you want the sheet associated with a certain control or view, you could position the sheet so that it appears to originate from the object (through animation) or is positioned next to it.

Neither the rect parameter nor the returned NSRect value define the boundary of the sheet. They indicate where the top-left edge of the sheet is attached to the window. The origin is expressed in window coordinates; the default origin.y value is the height of the content view and the default origin.x value is 0. The size.width value indicates the width and behavior of the initial animation; if size.width is narrower than the sheet, the sheet genies out from the specified location, and if size.width is wider than the sheet, the sheet slides out. You cannot affect the size of the sheet through the size.width and size.height fields. It is recommended that you specify zero for the size.height value as this field may have additional meaning in a future release.

Availability
  • Available in OS X v10.3 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

window:willResizeForVersionBrowserWithMaxPreferredSize:maxAllowedSize:

Tells the delegate the the window will resize for presentation during version browsing.

- (NSSize)window:(NSWindow *)window willResizeForVersionBrowserWithMaxPreferredSize:(NSSize)maxPreferredSize maxAllowedSize:(NSSize)maxAllowedSize
Parameters
window

The window being presented in a version browser.

maxPreferredSize

The maximum size the version browser would prefer the window to be.

maxAllowedSize

The maximum allowed size for the window (the full-screen frame minus the margins required to ensure the Versions controls are still visible).

Return Value

The size that the window should be.

Discussion

Windows entering the version browser will be resized to the size returned by this method. If either dimension of the returned size is larger than the maxPreferredFrameSize, the window will also be scaled down to ensure it fits properly in the version browser.

If this method is not implemented, the version browser will use windowWillUseStandardFrame:defaultFrame: to determine the resulting window frame size.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:willUseFullScreenContentSize:

Called to allow the delegate to modify the full-screen content size.

- (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize
Parameters
window

The window to enter to full-screen mode.

proposedSize

The proposed window size.

Return Value

The window size to use when displaying content size.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

window:willUseFullScreenPresentationOptions:

Returns the presentation options the window uses when transitioning to full-screen mode.

- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
Parameters
window

The window to enter to full-screen mode.

proposedOptions

The proposed options. See NSApplicationPresentationOptions for the possible values.

Return Value

The options the window should use when transitioning to full-screen mode. These may be the same as the proposedOptions or may be modified.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidBecomeKey:

Informs the delegate that the window has become the key window.

- (void)windowDidBecomeKey:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidBecomeKeyNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidBecomeMain:

Informs the delegate that the window has become main.

- (void)windowDidBecomeMain:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidBecomeMainNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidChangeBackingProperties:

Tells the delegate that the window backing properties changed.

- (void)windowDidChangeBackingProperties:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidChangeBackingPropertiesNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

The notification NSWindowDidChangeBackingPropertiesNotification is posted on OS X v10.7.3 or later when a window’s backing scale factor or its color space changes. You should watch for this notification instead of NSWindowDidChangeScreenProfileNotification if your app runs on a system version on which the backing properties notification is available.

Many apps won’t have the need to watch for this notification, but those that perform sophisticated color handling or manually manage their own cache of window-resolution or color-space-appropriate bitmapped images will find this notification useful as a prompt to invalidate caches or schedule other reassessment for the new resolution or color space. The notification’s userInfo dictionary specifies the window’s previous backing scale factor (retrieved with the keyNSBackingPropertyOldScaleFactorKey) and color space (retrieved with the key NSBackingPropertyOldColorSpaceKey). You can compare these with the window’s new previous backing scale factor and color space at the time of the notification to determine which properties changed.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidChangeOcclusionState:

Tells the delegate that the window changed its occlusion state.

- (void)windowDidChangeOcclusionState:(NSNotification *)notification
Parameters
notification

An NSWindowDidChangeOcclusionStateNotification notification.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSWindow.h

windowDidChangeScreen:

Tells the delegate that the window has changed screens.

- (void)windowDidChangeScreen:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidChangeScreenNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidChangeScreenProfile:

Tells the delegate that the window has changed screen display profiles.

- (void)windowDidChangeScreenProfile:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidChangeScreenProfileNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

If your app runs on OS X v10.7.3 or later, you should instead watch for the notification NSWindowDidChangeBackingPropertiesNotification.

Availability
  • Available in OS X v10.4 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidDeminiaturize:

Tells the delegate that the window has been deminimized.

- (void)windowDidDeminiaturize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidDeminiaturizeNotification

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidEndLiveResize:

Informs the delegate that a live resize operation on the window has ended.

- (void)windowDidEndLiveResize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidEndLiveResizeNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSWindow.h

windowDidEndSheet:

Tells the delegate that the window has closed a sheet.

- (void)windowDidEndSheet:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidEndSheetNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.1 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidEnterFullScreen:

The window just entered full-screen mode.

- (void)windowDidEnterFullScreen:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidEnterFullScreenNotification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidEnterVersionBrowser:

Tells the delegate that the window just entered version browsing.

- (void)windowDidEnterVersionBrowser:(NSNotification *)notification
Parameters
notification

An NSWindowDidEnterVersionBrowserNotification notification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidExitFullScreen:

The window is about to enter full-screen mode.

- (void)windowDidExitFullScreen:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidExitFullScreenNotification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidExitVersionBrowser:

Tells the delegate that the window just left version browsing.

- (void)windowDidExitVersionBrowser:(NSNotification *)notification
Parameters
notification

An NSWindowDidExitVersionBrowserNotification notification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidExpose:

Tells the delegate that the window has been exposed.

- (void)windowDidExpose:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidExposeNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidFailToEnterFullScreen:

Called if the window failed to enter full-screen mode.

- (void)windowDidFailToEnterFullScreen:(NSWindow *)window
Parameters
window

The window that failed to enter to full-screen mode.

Discussion

In some cases, the transition to enter full-screen mode can fail, due to being in the midst of handling some other animation or user gesture. This method indicates that there was an error, and you should clean up any work you may have done to prepare to enter full-screen mode.

This message is sent whether or not the delegate indicated a custom animation by returning non-nil from customWindowsToEnterFullScreenForWindow:.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidFailToExitFullScreen:

Called if the window failed to exit full-screen mode.

- (void)windowDidFailToExitFullScreen:(NSWindow *)window
Parameters
window

The window that failed to exit to full-screen mode.

Discussion

In some cases, the transition to exit full-screen mode can fail, due to being in the midst of handling some other animation or user gesture. This method indicates that there was an error, and you should clean up any work you may have done to prepare to exit full-screen mode.

This message is sent whether or not the delegate indicated a custom animation by returning non-nil from customWindowsToExitFullScreenForWindow:.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowDidMiniaturize:

Tells the delegate that the window has been minimized.

- (void)windowDidMiniaturize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidMiniaturizeNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidMove:

Tells the delegate that the window has moved.

- (void)windowDidMove:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidMoveNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidResignKey:

Informs the delegate that the window has resigned key window status.

- (void)windowDidResignKey:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidResignKeyNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidResignMain:

Informs the delegate that the window has resigned main window status.

- (void)windowDidResignMain:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidResignMainNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidResize:

Informs the delegate that the window has been resized.

- (void)windowDidResize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidResizeNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowDidUpdate:

Tells the delegate that the window received an update message.

- (void)windowDidUpdate:(NSNotification *)notification
Parameters
notification

A notification named NSWindowDidUpdateNotification

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowShouldClose:

Tells the delegate that the user has attempted to close a window or the window has received a performClose: message.

- (BOOL)windowShouldClose:(id)sender
Parameters
sender

The window being closed.

Return Value

YES to allow sender to be closed; otherwise, NO.

Discussion

This method may not always be called during window closing. Specifically, this method is not called when a user quits an application.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowShouldZoom:toFrame:

Asks the delegate whether the specified window should zoom to the specified frame.

- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
Parameters
window

The window being zoomed.

newFrame

The rectangle to which the specified window is being zoomed.

Return Value

YES to allow window’s frame to become newFrame; otherwise, NO.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillBeginSheet:

Notifies the delegate that the window is about to open a sheet.

- (void)windowWillBeginSheet:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillBeginSheetNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.1 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillClose:

Tells the delegate that the window is about to close.

- (void)windowWillClose:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillCloseNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillEnterFullScreen:

The window is about to enter full-screen mode.

- (void)windowWillEnterFullScreen:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillEnterFullScreenNotification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowWillEnterVersionBrowser:

Tells the delegate the the window is about to enter version browsing.

- (void)windowWillEnterVersionBrowser:(NSNotification *)notification
Parameters
notification

An NSWindowWillEnterVersionBrowserNotification notification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowWillExitFullScreen:

The window is about to exit full-screen mode.

- (void)windowWillExitFullScreen:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillExitFullScreenNotification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowWillExitVersionBrowser:

Tells the delegate that the window is about to leave version browsing.

- (void)windowWillExitVersionBrowser:(NSNotification *)notification
Parameters
notification

An NSWindowWillExitVersionBrowserNotification notification.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSWindow.h

windowWillMiniaturize:

Tells the delegate that the window is about to be minimized.

- (void)windowWillMiniaturize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillMiniaturizeNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillMove:

Tells the delegate that the window is about to move.

- (void)windowWillMove:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillMoveNotification.

Discussion

You can retrieve the NSWindow object in question by sending object to notification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillResize:toSize:

Tells the delegate that the window is being resized (whether by the user or through one of the setFrame... methods other than setFrame:display:).

- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
Parameters
sender

The window being resized.

frameSize

The size to which the specified window is being resized.

Return Value

A custom size to which the specified window will be resized.

Discussion

The frameSize contains the size (in screen coordinates) sender will be resized to. To resize to a different size, simply return the desired size from this method; to avoid resizing, return the current size. sender’s minimum and maximum size constraints have already been applied when this method is called.

While the user is resizing a window, the delegate is sent a series of windowWillResize:toSize: messages as the window’s outline is dragged. The window’s outline is displayed at the constrained size as set by this method.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillReturnFieldEditor:toObject:

Tells the delegate that the field editor for a text-displaying object has been requested.

- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client
Parameters
sender

The window requesting the field editor from the delegate.

client

A text-displaying object to be associated with the field editor. If nil, the requested field editor is the default.

Return Value

The field editor for client; returns nil when the delegate has no field editor to assign.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillReturnUndoManager:

Tells the delegate that the window’s undo manager has been requested. Returns the appropriate undo manager for the window.

- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window
Parameters
window

The window whose undo manager is being requested.

Return Value

The appropriate undo manager for the specified window.

Discussion

If this method is not implemented by the delegate, the window creates anNSUndoManager for window.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h

windowWillStartLiveResize:

Informs the delegate that the window is about to be live resized.

- (void)windowWillStartLiveResize:(NSNotification *)notification
Parameters
notification

A notification named NSWindowWillStartLiveResizeNotification.

Discussion

You can retrieve the window object in question by sending object to notification.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSWindow.h

windowWillUseStandardFrame:defaultFrame:

Called by NSWindow’s zoom: method while determining the frame a window may be zoomed to.

- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame
Parameters
window

The window whose frame size is being determined.

newFrame

The size of the current screen, which is the screen containing the largest part of the window’s current frame, possibly reduced on the top, bottom, left, or right, depending on the current interface style. The frame is reduced on the top to leave room for the menu bar.

Return Value

The specified window’s standard frame.

Discussion

The standard frame for a window should supply the size and location that are “best” for the type of information shown in the window, taking into account the available display or displays. For example, the best width for a window that displays a word-processing document is the width of a page or the width of the display, whichever is smaller. The best height can be determined similarly. On return from this method, the zoom: method modifies the returned standard frame, if necessary, to fit on the current screen.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSWindow.h