Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Implements | |
Package | com.apple.cocoa.application |
Companion guide |
An NSWindow manages an onscreen window, coordinating the display and event handling for its NSViews. Interface Builder allows you to create and set up NSWindows, but there are many things you may wish to do programmatically as well.
Manages a view hierarchy.
Uses a delegate.
Distributes events to view objects.
Provides a field editor to view objects.
makeKeyAndOrderFront
Moves the NSWindow to the front and makes it the key window.
makeFirstResponder
Sets the first responder in the NSWindow.
fieldEditorForObject
Returns the shared text object for the NSWindow.
setContentView
Sets the root-level NSView in the NSWindow.
representedFilename
Returns the filename whose contents the NSWindow presents.
setDocumentEdited
Sets whether the NSWindow’s represented file needs to be saved.
setTitle
Sets the title of the NSWindow.
setTitleWithRepresentedFilename
Sets the title of the NSWindow in a readable format for filenames.
The NSWindow class defines objects that manage and coordinate the windows an application displays on the screen. A single NSWindow object corresponds to at most one onscreen window. The two principal functions of NSWindow are to provide an area in which NSViews can be placed and to accept and distribute, to the appropriate NSViews, events the user instigates through actions with the mouse and keyboard.
Note: Although NSWindow inherits the NSCoding protocol from NSResponder, NSWindow does not support coding. Legacy support for archivers exists but its use is deprecated and may not work. Any attempt to archive or unarchive an NSWindow using a keyed coding object throws an InvalidArgumentException
.
contentRectForFrameRect
frameRectForContentRect
minFrameWidthWithTitle
contentRectForFrameRect
frameRectForContentRect
frame
setFrame
animationResizeTime
setFrameOrigin
setFrameTopLeftPoint
setContentSize
cascadeTopLeftFromPoint
center
resizeFlags
performZoom
zoom
isZoomed
showsResizeIndicator
setShowsResizeIndicator
isMovableByWindowBackground
setMovableByWindowBackground
preservesContentDuringLiveResize
setPreservesContentDuringLiveResize
maxSize
minSize
setMaxSize
setMinSize
setAspectRatio
aspectRatio
setResizeIncrements
resizeIncrements
constrainFrameRectToScreen
setContentAspectRatio
contentAspectRatio
setContentResizeIncrements
contentResizeIncrements
setContentMaxSize
contentMaxSize
setContentMinSize
contentMinSize
removeFrameUsingName
saveFrameUsingName
setFrameUsingName
setFrameAutosaveName
frameAutosaveName
setFrameFromString
stringWithSavedFrame
becomeKeyWindow
canBecomeKeyWindow
isKeyWindow
makeKeyAndOrderFront
makeKeyWindow
resignKeyWindow
becomeMainWindow
canBecomeMainWindow
isMainWindow
makeMainWindow
resignMainWindow
autorecalculatesKeyViewLoop
recalculateKeyViewLoop
setAutorecalculatesKeyViewLoop
defaultButtonCell
setDefaultButtonCell
disableKeyEquivalentForDefaultButtonCell
enableKeyEquivalentForDefaultButtonCell
display
displayIfNeeded
setViewsNeedDisplay
viewsNeedDisplay
useOptimizedDrawing
setAutodisplay
isAutodisplay
update
graphicsContext
disableScreenUpdatesUntilFlush
windowNumber
gState
deviceDescription
setBackingType
backingType
setOneShot
isOneShot
defaultDepthLimit
setDepthLimit
depthLimit
setDynamicDepthLimit
hasDynamicDepthLimit
canStoreColor
currentEvent
nextEventMatchingMask
discardEventsMatchingMask
postEvent
sendEvent
tryToPerform
keyDown
mouseLocationOutsideOfEventStream
setAcceptsMouseMovedEvents
acceptsMouseMovedEvents
ignoresMouseEvents
setIgnoresMouseEvents
setInitialFirstResponder
initialFirstResponder
selectKeyViewFollowingView
selectKeyViewPrecedingView
selectNextKeyView
selectPreviousKeyView
keyViewSelectionDirection
miniaturize
performMiniaturize
deminiaturize
isMiniaturized
setMiniwindowImage
miniwindowImage
setMiniwindowTitle
miniwindowTitle
areCursorRectsEnabled
enableCursorRects
disableCursorRects
discardCursorRects
invalidateCursorRectsForView
resetCursorRects
concludeDragOperation
dragImage
draggingEntered
draggingExited
draggingUpdated
performDragOperation
prepareForDragOperation
registerForDraggedTypes
unregisterDraggedTypes
setContentView
contentView
setBackgroundColor
backgroundColor
styleMask
setHasShadow
hasShadow
invalidateShadow
setAlphaValue
alphaValue
setOpaque
isOpaque
windowDidBecomeKey
delegate method
windowDidBecomeMain
delegate method
windowDidResignKey
delegate method
windowDidResignMain
delegate method
windowDidChangeScreen
delegate method
windowDidChangeScreenProfile
delegate method
windowWillMove
delegate method
windowDidMove
delegate method
windowWillResize
delegate method
windowDidResize
delegate method
windowShouldZoom
delegate method
windowWillUseStandardFrame
delegate method
windowWillMiniaturize
delegate method
windowDidMiniaturize
delegate method
windowDidDeminiaturize
delegate method
windowShouldClose
delegate method
windowWillClose
delegate method
windowDidExpose
delegate method
windowDidUpdate
delegate method
windowWillBeginSheet
delegate method
windowDidEndSheet
delegate method
windowWillPositionSheet
delegate method
windowWillReturnFieldEditor
delegate method
windowWillReturnUndoManager
delegate method
Creates a new NSWindow object, whose content rectangle is specified relative to the lower-left corner of the main screen.
public NSWindow
()
This constructor calls the following constructor with contentRect of (100.0, 100.0, 100.0, 100.0), styleMask of TitledWindowMask
, backingType of BackingStoreBuffered
, and defer set to false
.
Creates a new NSWindow object, whose content rectangle is specified relative to the lower-left corner of the main screen.
public NSWindow
(NSRect contentRect, int styleMask, int backingType, boolean defer)
The contentRect argument specifies the location and size of the NSWindow’s content area in screen coordinates. Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.
The styleMask argument specifies the receiver’s style. Either it can be BorderlessWindowMask
, or it can contain any of the options described in the constants section, combined using the C bitwise OR operator.
Borderless windows display none of the usual peripheral elements and are generally useful only for display or caching purposes; you should normally not need to create them. Also, note that an NSWindow’s style mask should include TitledWindowMask
if it includes any of the others.
The backingType argument specifies how the drawing done in the receiver is buffered by the object’s window device, and possible values are described in the constants section.
The defer argument determines whether the window server creates a window device for the new object immediately. If defer is true
, it defers creating the window until the receiver is moved onscreen. All display messages sent to the NSWindow or its NSViews are postponed until the window is created, just before it’s moved onscreen. Deferring the creation of the window improves launch time and minimizes the virtual memory load on the window server.
The new NSWindow creates an instance of NSView to be its default content view. You can replace it with your own object by using the setContentView
method.
Creates an NSWindow object, whose content rectangle is specified relative to the lower-left corner of aScreen.
public NSWindow
(NSRect contentRect, int styleMask, int bufferingType, boolean defer, NSScreen aScreen)
Otherwise this method is equivalent to the preceding constructor.
If aScreen is null
, the content rectangle is interpreted relative to the lower-left corner of the main screen. The main screen is the one that contains the current key window or, if there is no key window, the one that contains the main menu. If there’s neither a key window nor a main menu (if there’s no active application), the main screen is the one where the origin of the screen coordinate system is located.
Returns the content rectangle used by an NSWindow with a frame rectangle of frameRect and a style mask of aStyle.
public static NSRect contentRectForFrameRect
(NSRect frameRect, int aStyle)
Both frameRect and the returned content rectangle are expressed in screen coordinates. See the constants section for a list of style mask values.
Returns the default depth limit for instances of NSWindow.
public static int defaultDepthLimit
()
This limit is determined by the depth of the deepest screen level available to the window server.
Returns the frame rectangle used by an NSWindow with a content rectangle of contentRect and a style mask of aStyle.
public static NSRect frameRectForContentRect
(NSRect contentRect, int aStyle)
Both contentRect and the returned frame rectangle are expressed in screen coordinates. See the constants section for a list of style mask values.
This method does nothing; it is here for backward compatibility.
public static void menuChanged
(NSMenu aMenu)
menu
(NSResponder)Returns the minimum width an NSWindow’s frame rectangle must have for it to display all of aTitle, given aStyle as its style mask.
public static float minFrameWidthWithTitle
(String aTitle, int aStyle)
See the constants section for a list of acceptable style mask values.
Removes the frame data stored under name from the application’s user defaults.
public static void removeFrameUsingName
(String name)
Returns a new instance of the given standard button, sized appropriately for the styleMask.
public static NSButton standardWindowButtonForStyleMask
(int button, int styleMask)
The caller is responsible for adding the button to the view hierarchy and for setting the target to be the window.
Returns true
if the receiver accepts and distributes mouse-moved events, false
if it doesn’t.
public boolean acceptsMouseMovedEvents
()
NSWindows by default don’t accept mouse-moved events.
childWin is ordered either above (Above
) or below (Below
) the receiver, and maintained in that relative place for subsequent ordering operations involving either window.
public void addChildWindow
(NSWindow childWin, int place)
While this attachment is active, moving childWin will not cause the receiver to move (as in sliding a drawer in or out), but moving the receiver will cause childWin to move.
Note that you should not create cycles between parent and child windows. For example, you should not add window B as child of window A, then add window A as a child of window B.
Returns whether the receiver can display tool tips even when the application is in the background.
public boolean allowsToolTipsWhenApplicationIsInactive
()
Default is false
.
Returns the receiver’s alpha value.
public float alphaValue
()
Subclasses can override this method to control the total time for the frame change.
public double animationResizeTime
(NSRect newFrame)
newFrame is the rect passed into setFrame
.
The default implementation uses the value from the NSWindowResizeTime
user default as the time in seconds to resize by 150 pixels. If this value is unspecified, NSWindowResizeTime
is 0.20 seconds (this default value may be differ in different releases of Mac OS X).
Returns true
if the receiver’s cursor rectangles are enabled, false
if they’re not.
public boolean areCursorRectsEnabled
()
enableCursorRects
addCursorRect
(NSView)Returns the receiver’s size aspect ratio.
public NSSize aspectRatio
()
The size of the receiver’s frame rectangle is constrained to integral multiples of this ratio when the user resizes it. You can set an NSWindow’s size to any ratio programmatically.
Returns the sheet attached to the receiver.
public NSWindow attachedSheet
()
If the receiver does not have a sheet attached, this method returns null
.
Returns true
if the window automatically recalculates the key view loop when views are added; otherwise returns false
.
public boolean autorecalculatesKeyViewLoop
()
Returns the color of the receiver’s background.
public NSColor backgroundColor
()
Returns the receiver’s backing store type.
public int backingType
()
The possible return values are described in the constants section.
Invoked automatically to inform the receiver that it has become the key window; never invoke this method directly.
public void becomeKeyWindow
()
This method reestablishes the receiver’s first responder, sends the becomeKeyWindow
message to that object if it responds, and posts a WindowDidBecomeKeyNotification
to the default notification center.
Invoked automatically to inform the receiver that it has become the main window; never invoke this method directly.
public void becomeMainWindow
()
This method posts a WindowDidBecomeMainNotification
to the default notification center.
Stores the receiver’s raster image from aRect, which is expressed in the receiver’s base coordinate system.
public void cacheImageInRect
(NSRect aRect)
This method allows the receiver to perform temporary drawing, such as a band around the selection as the user drags the mouse, and to quickly restore the previous image by invoking restoreCachedImage
and flushWindowIfNeeded
. The next time the window displays, it discards its cached image rectangles. You can also explicitly use discardCachedImage
to free the memory occupied by cached image rectangles. aRect is made integral before caching the image to avoid antialiasing artifacts.
Only the last cached rectangle is remembered and can be restored.
Returns true
if the receiver can become the key window, false
if it can’t.
public boolean canBecomeKeyWindow
()
Attempts to make the receiver the key window are abandoned if this method returns false
. NSWindow’s implementation returns true
if the receiver has a title bar or a resize bar, false
otherwise.
Returns true
if the receiver can become the main window, false
if it can’t.
public boolean canBecomeMainWindow
()
Attempts to make the receiver the main window are abandoned if this method returns false
. NSWindow’s implementation returns true
if the receiver is visible, is not an NSPanel, and has a title bar or a resize mechanism. Otherwise it returns false
.
Returns whether the receiver can be hidden during NSApplication’s hide
.
public boolean canHide
()
The default is true
.
Returns true
if the receiver has a depth limit that allows it to store color values, false
if it doesn’t.
public boolean canStoreColor
()
depthLimit
shouldDrawColor
(NSView)Positions the receiver's top left at topLeftPoint, unless topLeftPoint is NSPoint.ZeroPoint
in which case the receiver is not moved except as needed to constrain to the visible screen.
public NSPoint cascadeTopLeftFromPoint
(NSPoint topLeftPoint)
Returns a point shifted from top left of the receiver that can be passed to a subsequent invocation of cascadeTopLeftFromPoint
to position the next NSWindow so the title bars of both NSWindows are fully visible.
Both topLeftPoint and the return value are expressed in screen coordinates.
Sets the receiver’s location to the center of the screen.
public void center
()
The receiver is placed exactly in the center horizontally and somewhat above center vertically. Such a placement carries a certain visual immediacy and importance. This method doesn’t put the receiver onscreen, however; use makeKeyAndOrderFront
to do that.
You typically use this method to place an NSWindow—most likely an alert dialog—where the user can’t miss it. This method is invoked automatically when an NSPanel is placed on the screen by NSApplication’s runModalForWindow
method.
Returns an array of the receiver’s attached child windows.
public NSArray childWindows
()
Removes the receiver from the screen.
public void close
()
A window doesn’t have to be visible to receive the close message. For example, when the application terminates, it sends the close message to all windows in its window list, even those that are not currently visible.
The close method posts a WindowWillCloseNotification
to the default notification center.
The close method differs in two important ways from the performClose
method:
It does not attempt to send a windowShouldClose
message to the receiver or its delegate.
It does not simulate the user clicking the close button by momentarily highlighting the button.
Use performClose
if you need these features.
public void concludeDragOperation
(NSDraggingInfo draggingInfo)
Invoked when the dragging operation is complete and the previous performDragOperation
returned true
. draggingInfo contains details about the dragging operation. This method allows you to perform any tidying up that is needed, such as updating the visual representation now the dragged data has been incorporated. This is the last message sent during a dragging session.
Modifies and returns frameRect so that its top edge lies on aScreen.
public NSRect constrainFrameRectToScreen
(NSRect frameRect, NSScreen aScreen)
If the receiver is resizable and the receiver’s height is greater than the screen height, the rectangle’s height is adjusted to fit within the screen as well. The rectangle’s width and horizontal location are unaffected. You shouldn’t need to invoke this method yourself; it’s invoked automatically (and the modified frame is used to locate and set the size of the receiver) whenever a titled NSWindow is placed onscreen and whenever its size is changed.
Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.
Returns the aspect ratio (height in relation to width) of the receiver’s content view.
public NSSize contentAspectRatio
()
Returns the maximum size of the receiver’s content view.
public NSSize contentMaxSize
()
Returns the minimum size of the receiver’s content view.
public NSSize contentMinSize
()
Returns the rectangle bounding the receiver’s content view given the frame rectangle frameRect.
public NSRect contentRectForFrameRect
(NSRect frameRect)
Both frameRect and the returned content rectangle are expressed in screen coordinates. The receiver uses its current style mask in computing the content rectangle. See the constants sectionfor a list of style mask values. The main advantage of this instance-method counterpart to contentRectForFrameRect
is that it allows you to take toolbars into account when converting between content and frame rectangles. (The toolbar is not included in the content rectangle.)
Returns the size of increments used during resizing of the receiver’s content rectangle.
public NSSize contentResizeIncrements
()
Resizing of the content rectangle is constrained to integral multiples of the returned height and width.
Returns the receivers’s content view, the highest accessible NSView object in the receiver’s view hierarchy.
public NSView contentView
()
Returns aPoint converted from the receiver’s base coordinate system to the screen coordinate system.
public NSPoint convertBaseToScreen
(NSPoint aPoint)
convertScreenToBase
convertPointToView
(NSView)Returns aPoint converted from the screen coordinate system to the receiver’s base coordinate system.
public NSPoint convertScreenToBase
(NSPoint aPoint)
convertBaseToScreen
convertRectFromView
(NSView)Returns the event currently being processed by the application, by invoking NSApplication’s currentEvent
method.
public NSEvent currentEvent
()
Returns EPS data that draws the region of the receiver within aRect (expressed in the receiver’s base coordinate system).
public NSData dataWithEPSInsideRect
(NSRect aRect)
This data can be placed on a pasteboard, written to a file, or used to create an NSImage object.
dataWithEPSInsideRect
(NSView)writeEPSInsideRectToPasteboard
(NSView)Returns PDF data that draws the region of the receiver within aRect (expressed in the receiver’s base coordinate system).
public NSData dataWithPDFInsideRect
(NSRect aRect)
This data can be placed on a pasteboard, written to a file, or used to create an NSImage object.
dataWithPDFInsideRect
(NSView)writePDFInsideRectToPasteboard
(NSView)Returns the deepest screen the receiver is on (it may be split over several screens), or null
if the receiver is offscreen.
public NSScreen deepestScreen
()
Returns the button cell that performs as if clicked when the NSWindow receives a Return (or Enter) key event.
public NSButtonCell defaultButtonCell
()
This cell draws itself as the focal element for keyboard interface control, unless another button cell is focused on, in which case the default button cell temporarily draws itself as normal and disables its key equivalent.
The window receives a Return key event if no responder in its responder chain claims it, or if the user presses the Control key along with the Return key.
setDefaultButtonCell
disableKeyEquivalentForDefaultButtonCell
enableKeyEquivalentForDefaultButtonCell
Returns the receiver’s delegate, or null
if it doesn’t have a delegate.
public Object delegate
()
This action method deminiaturizes the receiver.
public void deminiaturize
(Object sender)
Invoke this method to programmatically deminiaturize a miniaturized window in the dock.
Returns the depth limit of the receiver.
public int depthLimit
()
Returns a dictionary containing information about the receiver’s resolution, color depth, and so on.
public NSDictionary deviceDescription
()
This information is useful for tuning images and colors to the window’s display capabilities. The contents of the dictionary are:
Dictionary Key |
Value |
---|---|
|
An NSSize that describes the receiver’s raster resolution in dots per inch (dpi). |
|
A String giving the name of the receiver’s color space. See the constants section in NSGraphics for a list of possible values. |
|
A Number containing an integer that gives the bit depth of the receiver’s raster image (2-bit, 8-bit, and so forth). |
|
A result of |
|
An NSSize that gives the size of the receiver’s frame rectangle. |
deviceDescription
(NSScreen)bestRepresentationForDevice
(NSImage)colorUsingColorSpaceName
(NSColor)Disables all cursor rectangle management within the receiver.
public void disableCursorRects
()
Use this method when you need to do some special cursor manipulation and you don’t want the Application Kit interfering.
Disables the flushWindow
method for the receiver.
public void disableFlushWindow
()
If the receiver is buffered, disabling flushWindow
prevents drawing from being automatically flushed by NSView’s display...
methods from the receiver’s backing store to the screen. This method permits several NSViews to be drawn before the results are shown to the user.
Flushing should be disabled only temporarily, while the NSWindow’s display is being updated. Each disableFlushWindow
message must be paired with a subsequent enableFlushWindow
message. Invocations of these methods can be nested; flushing isn’t reenabled until the last (unnested) enableFlushWindow
message is sent.
Disables the default button cell’s key equivalent, so it doesn’t perform a click when the user presses Return (or Enter).
public void disableKeyEquivalentForDefaultButtonCell
()
See the method description for defaultButtonCell
for more information.
Disables the receiver’s screen updates until the window is flushed.
public void disableScreenUpdatesUntilFlush
()
This method can be invoked to synchronize hardware surface flushes with the window’s flushes. The receiver immediately disables screen updates using the function NSDisableScreenUpdates
and re-enables screen updates when the window flushes. Sending this message multiple times during a window update cycle has no effect.
Discards all of the receiver’s cached image rectangles.
public void discardCachedImage
()
An NSWindow automatically discards its cached image rectangles when it displays.
Invalidates all cursor rectangles in the receiver.
public void discardCursorRects
()
This method is invoked by resetCursorRects
to clear out existing cursor rectangles before resetting them. You shouldn’t invoke it in the code you write, but might want to override it to change its behavior.
Forwards the message to the NSApplication object, which handles it as described in the NSApplication class specification.
public void discardEventsMatchingMask
(int mask, NSEvent lastEvent)
Passes a display message down the receiver’s view hierarchy, thus redrawing all NSViews within the receiver, including the frame view that draws the border, title bar, and other peripheral elements.
public void display
()
You rarely need to invoke this method. NSWindows normally record which of their NSViews need display and display them automatically on each pass through the event loop.
display
(NSView)displayIfNeeded
isAutodisplay
Passes a displayIfNeeded
message down the receiver’s view hierarchy, thus redrawing all NSViews that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements.
public void displayIfNeeded
()
This method is useful when you want to modify some number of NSViews and then display only the ones that were modified.
You rarely need to invoke this method. NSWindows normally record which of their NSViews need display and display them automatically on each pass through the event loop.
display
displayIfNeeded
(NSView)setNeedsDisplay
(NSView)isAutodisplay
Returns true
if the window context should be updated when the screen profile changes or when the window moves to a different screen.
public boolean displaysWhenScreenProfileChanges
()
Returns false
(the default value) if the window context should stay the same despite profile changes.
public int draggingEntered
(NSDraggingInfo draggingInfo)
Invoked when a dragged image enters the receiver. Specifically, this method is invoked when the mouse pointer enters the receiver’s frame rectangle. draggingInfo contains details about the dragging operation.
Returns a value indicating which dragging operation will be performed when the image is released. In deciding which dragging operation to return, you should evaluate the overlap between both the dragging operations allowed by the source and the dragging operations and pasteboard data types the receiver supports. The returned value should be one of the following:
Option |
Meaning |
---|---|
|
The data represented by the image will be copied. |
|
The data will be shared. |
|
The operation will be defined by the destination. |
|
The operation is negotiated privately between the source and the destination. |
|
Combines all the above. |
If none of the operations is appropriate, returns NSDraggingInfo.DragOperationNone
.
Invoked when the dragged image exits the receiver’s frame rectangle.
public void draggingExited
(NSDraggingInfo draggingInfo)
draggingInfo contains details about the dragging operation.
public int draggingUpdated
(NSDraggingInfo draggingInfo)
Invoked periodically as the dragged image is held within the receiver. The messages continue until the image is either released or dragged out of the receiver. draggingInfo contains details about the dragging operation. Returns one of the dragging operation options listed under draggingEntered
.
This method provides you with an opportunity to modify the dragging operation depending on the position of the mouse pointer inside of the receiver. For example, you may have several graphics or areas of text contained within the same view and wish to tailor the dragging operation or to ignore the drag event completely, depending upon which object is underneath the mouse pointer at the time when the user releases the dragged image and performDragOperation
is invoked.
You typically examine the contents of the pasteboard in draggingEntered
, as this method is invoked only once, rather than in this method, which is invoked multiple times.
Only one window at a time receives a sequence of draggingUpdated
messages. If the mouse pointer is within the bounds of two overlapping windows that are both valid destinations, the uppermost window receives these messages until the image is either released or dragged out.
Begins a dragging session.
public void dragImage
(NSImage anImage, NSPoint aPoint, NSSize initialOffset, NSEvent theEvent, NSPasteboard pboard, Object sourceObject, boolean slideBack)
This method should be invoked only from within a view’s implementation of the mouseDown
or mouseDragged
methods (which overrides the version defined in NSResponder). Essentially the same as NSView’s method of the same name, except that aPoint is given in the NSWindow’s base coordinate system. See the description of NSView’s dragImage
for more information.
Returns the collection of drawers associated with the receiver.
public NSArray drawers
()
Reenables cursor rectangle management within the receiver after a disableCursorRects
message.
public void enableCursorRects
()
Reenables the flushWindow
method for the receiver after it was disabled through a previous disableFlushWindow
message.
public void enableFlushWindow
()
Reenables the default button cell’s key equivalent, so it performs a click when the user presses Return (or Enter).
public void enableKeyEquivalentForDefaultButtonCell
()
See the method description for defaultButtonCell
for more information.
Forces the field editor, which anObject is assumed to be using, to give up its first responder status and prepares it for its next assignment.
public void endEditingForObject
(Object anObject)
If the field editor is the first responder, it’s made to resign that status even if its resignFirstResponder
method returns false
. This registration forces the field editor to send a textDidEndEditing
message to its delegate. The field editor is then removed from the view hierarchy, its delegate is set to null
, and it’s emptied of any text it may contain.
This method is typically invoked by the object using the field editor when it’s finished. Other objects normally change the first responder by simply using makeFirstResponder
, which allows a field editor or other object to retain its first responder status if, for example, the user has entered an invalid value. The endEditingForObject
method should be used only as a last resort if the field editor refuses to resign first responder status. Even in this case, you should always allow the field editor a chance to validate its text and take whatever other action it needs first. You can do this by first trying to make the NSWindow the first responder.
Returns the receiver’s field editor, creating it if needed if createFlag is true
.
public NSText fieldEditorForObject
(boolean createFlag, Object anObject)
Returns null
if createFlag is false
and the field editor doesn’t exist. anObject is used to allow the receiver’s delegate to substitute another object in place of the field editor, as described below. The field editor may be in use by some view object, so be sure to properly dissociate it from that object before actually using it yourself (the appropriate way to do this is illustrated in the description of endEditingForObject
). Once you retrieve the field editor, you can insert it in the view hierarchy, set a delegate to interpret text events, and have it perform whatever editing is needed. Then, when it sends a textDidEndEditing
message to the delegate, you can get its text to display or store and remove the field editor using endEditingForObject
.
The field editor is a single NSTextView object that is shared among all the controls in a window for light text-editing needs. It is automatically instantiated when needed, and it can be used however your application sees fit. Typically, the field editor is used by simple text-bearing objects—for example, an NSTextField object uses its window’s field editor to display and manipulate text. The field editor can be shared by any number of objects, and so its state may be constantly changing. Therefore, it shouldn’t be used to display text that demands sophisticated layout (for this you should create a dedicated NSTextView object).
A freshly created NSWindow doesn’t have a field editor. After a field editor has been created for an NSWindow, the createFlag argument is ignored. By passing false
for createFlag and testing the return value, however, you can predicate an action on the existence of the field editor.
The receiver’s delegate can substitute a custom editor in place of the NSWindow’s field editor by implementing windowWillReturnFieldEditor
. The receiver sends this message to its delegate with itself and anObject as the arguments, and if the return value is not null
the NSWindow returns that object instead of its field editor. However, note the following:
If the NSWindow’s delegate is identical to anObject, windowWillReturnFieldEditor
isn’t sent.
The object returned by the delegate method, though it may become first responder, does not become the NSWindow’s field editor. Other objects continue to use the NSWindow’s established field editor.
Returns the receiver’s first responder.
public NSResponder firstResponder
()
makeFirstResponder
acceptsFirstResponder
(NSResponder)Flushes the receiver’s offscreen buffer to the screen if the receiver is buffered and flushing is enabled.
public void flushWindow
()
Does nothing for other display devices, such as a printer. This method is automatically invoked by NSWindow’s and NSView’s display
and displayIfNeeded
methods.
Flushes the receiver’s offscreen buffer to the screen if flushing is enabled and if the last flushWindow
message had no effect because flushing was disabled.
public void flushWindowIfNeeded
()
To avoid unnecessary flushing, use this method rather than flushWindow
to flush an NSWindow after flushing has been reenabled.
Returns the receiver’s frame rectangle.
public NSRect frame
()
The frame rectangle is always reckoned in the screen coordinate system.
Returns the name used to automatically save the receiver’s frame rectangle data in the defaults system, as set through setFrameAutosaveName
.
public String frameAutosaveName
()
If the receiver has an autosave name, its frame data is written whenever the frame rectangle changes.
Returns the receiver’s frame rectangle given the rectangle bounding the content view contentRect.
public NSRect frameRectForContentRect
(NSRect contentRect)
Both contentRect and the returned frame rectangle are expressed in screen coordinates. The receiver uses its current style mask in computing the frame rectangle. See the constants section for a list of style mask values. The major advantage of this instance-method counterpart to frameRectForContentRect
is that it allows you to take toolbars into account when converting between content and frame rectangles. (The toolbar is included in the frame rectangle but not the content rectangle.)
Returns the graphics context associated with the receiver for the current thread.
public NSGraphicsContext graphicsContext
()
Returns the graphics state object associated with the receiver.
public int gState
()
This graphics state is used by default for all NSViews in the receiver’s view hierarchy, but individual NSViews can be made to use their own with the NSView method allocateGState
.
Returns true
if the receiver’s depth limit can change to match the depth of the screen it’s on, false
if it can’t.
public boolean hasDynamicDepthLimit
()
Returns true
if the window has a shadow; otherwise returns false
.
public boolean hasShadow
()
Returns true
if the receiver is removed from the screen when its application is deactivated, false
if it remains onscreen.
public boolean hidesOnDeactivate
()
Return whether the receiver is transparent to mouse events.
public boolean ignoresMouseEvents
()
Returns the NSView that’s made first responder the first time the receiver is placed onscreen.
public NSView initialFirstResponder
()
setInitialFirstResponder
setNextKeyView
(NSView)Marks as invalid the cursor rectangles of aView, an NSView in the receiver’s view hierarchy, so they’ll be set up again when the receiver becomes key (or immediately if the receiver is key).
public void invalidateCursorRectsForView
(NSView aView)
resetCursorRects
resetCursorRects
(NSView)Invalidates the window shadow so that it is recomputed based on the current window shape.
public void invalidateShadow
()
Returns true
if the receiver automatically displays its views that are marked as needing it, false
if it doesn’t.
public boolean isAutodisplay
()
Automatic display typically occurs on each pass through the event loop.
setAutodisplay
displayIfNeeded
setNeedsDisplay
(NSView)Returns true
or false
according to the argument supplied with the last setDocumentEdited
message.
public boolean isDocumentEdited
()
Returns true
if the receiver’s title is omitted from the application’s Windows menu, false
if it is listed.
public boolean isExcludedFromWindowsMenu
()
Returns true
if the receiver’s flushing ability has been disabled; otherwise returns false
.
public boolean isFlushWindowDisabled
()
Returns true
if the receiver is the key window for the application, false
if it isn’t.
public boolean isKeyWindow
()
Returns true
if the receiver is the main window for the application, false
if it isn’t.
public boolean isMainWindow
()
Returns true
if the receiver has been miniaturized, false
if it hasn’t.
public boolean isMiniaturized
()
A miniaturized window is removed from the screen and replaced by a image, icon, or button that represents it, called the counterpart.
Returns true
if the receiver is movable by clicking and dragging anywhere in its background, false
if not.
public boolean isMovableByWindowBackground
()
A window with a style mask of NSTexturedBackgroundWindowMask
returns true
by default. Sheets and drawers cannot be movable by window background.
Returns true
if the window device the receiver manages is freed when it’s removed from the screen list, false
if not.
public boolean isOneShot
()
The default is false
.
Returns whether the receiver is opaque.
public boolean isOpaque
()
The default is true
.
Returns true
if the receiver is automatically released after being closed, false
if it’s simply removed from the screen.
public boolean isReleasedWhenClosed
()
The default for NSWindow is true
; the default for NSPanel is false
. Release when closed, however, is ignored for windows owned by window controllers.
Returns true
if the receiver has ever run as a modal sheet.
public boolean isSheet
()
Sheets are created using the NSPanel subclass.
Returns true
if the receiver is onscreen (even if it’s obscured by other windows).
public boolean isVisible
()
visibleRect
(NSView)Returns whether the receiver is in a zoomed state.
public boolean isZoomed
()
Handles theEvent keyboard event that may need to be interpreted as changing the key view or triggering a keyboard equivalent.
public void keyDown
(NSEvent theEvent)
selectNextKeyView
nextKeyView
(NSView)performMnemonic
(NSView)Returns the direction the receiver is currently using to change the key view.
public int keyViewSelectionDirection
()
This direction can be one of the values described in the constants section
Returns the level of the receiver as set using setLevel
.
public int level
()
Attempts to make aResponder the first responder for the receiver.
public boolean makeFirstResponder
(NSResponder aResponder)
If aResponder isn’t already the first responder, this method first sends a resignFirstResponder
message to the object that is. If that object refuses to resign, it remains the first responder, and this method immediately returns false
. If it returns true
, this method sends a becomeFirstResponder
message to aResponder. If aResponder accepts first responder status, this method returns true
. If it refuses, this method returns false
, and the NSWindow becomes first responder.
If aResponder is null
, this method still sends resignFirstResponder
to the current first responder. If the current first responder refuses to resign, it remains the first responder and this method immediately returns false
. If the current first responder returns true
from resignFirstResponder
, the receiver is made its own first responder and this method returns true
.
The Application Kit uses this method to alter the first responder in response to mouse-down events; you can also use it to explicitly set the first responder from within your program. aResponder is typically an NSView in the receiver’s view hierarchy. If this method is called explicitly, first send acceptsFirstResponder
to aResponder, and do not call makeFirstResponder
if acceptsFirstResponder
returns false
.
Use setInitialFirstResponder
to the set the first responder to be used when the window is brought onscreen for the first time.
becomeFirstResponder
(NSResponder)resignFirstResponder
(NSResponder)This action method moves the receiver to the front of the screen list, within its level, and makes it the key window.
public void makeKeyAndOrderFront
(Object sender)
Makes the receiver the key window.
public void makeKeyWindow
()
public void makeMainWindow
()
Makes the receiver the main window.
Returns the maximum size to which the receiver’s frame (including its title bar) can be sized either by the user or by the setFrame...
methods other than setFrame
.
public NSSize maxSize
()
This action method removes the receiver from the screen list and displays the miniaturized window in the dock.
public void miniaturize
(Object sender)
Returns the custom miniaturized window image of the receiver.
public NSImage miniwindowImage
()
The miniaturized window image is the image displayed in the dock when the window is minimized. If you did not assign a custom image to the window, this method returns null
.
Returns the title displayed in the receiver’s miniaturized window.
public String miniwindowTitle
()
Returns the minimum size to which the receiver’s frame (including its title bar) can be sized either by the user or by the setFrame...
methods other than setFrame
.
public NSSize minSize
()
Returns the current location of the mouse reckoned in the receiver’s base coordinate system, regardless of the current event being handled or of any events pending.
public NSPoint mouseLocationOutsideOfEventStream
()
For the same information in screen coordinates, use NSEvent's "mouseLocation"
.
currentEvent
(NSApplication)Invokes NSApplication’s nextEventMatchingMask
method, using mask as the first argument, with an unlimited expiration, a mode of NSApplication.EventTrackingRunLoopMode
, and a dequeue flag of true
.
public NSEvent nextEventMatchingMask
(int mask)
See the method description in the NSApplication class specification for more information.
Forwards the message to the global NSApplication object, NSApplication.sharedApplication()
.
public NSEvent nextEventMatchingMask
(int mask, NSDate expirationDate, String mode, boolean dequeue)
See the method description in the NSApplication class specification for more information.
This action method moves the receiver to the back of its level in the screen list, without changing either the key window or the main window.
public void orderBack
(Object sender)
This action method moves the receiver to the front of its level in the screen list, without changing either the key window or the main window.
public void orderFront
(Object sender)
Moves the receiver to the front of its level, even if its application isn’t active, but without changing either the key window or the main window.
public void orderFrontRegardless
()
Normally an NSWindow can’t be moved in front of the key window unless the NSWindow and the key window are in the same application. You should rarely need to invoke this method; it’s designed to be used when applications are cooperating in such a way that an active application (with the key window) is using another application to display data.
This action method takes the receiver out of the screen list.
public void orderOut
(Object sender)
If the receiver is the key or main window, the NSWindow immediately behind it is made key or main in its place. Calling the orderOut
method causes the receiver to be removed from the screen, but does not cause it to be released.
Repositions the receiver’s window device in the window server’s screen list.
public void orderWindow
(int place, int otherWindowNumber)
If place is Out
, the receiver is removed from the screen list and otherWindowNumber is ignored. If it’s Above,
the receiver is ordered immediately in front of the window whose window number is otherWindowNumber. Similarly, if place is Below
, the receiver is placed immediately behind the window represented by otherWindowNumber. If otherWindowNumber is 0, the receiver is placed in front of or behind all other windows in its level.
Returns the parent window to which the receiver is attached as a child.
public NSWindow parentWindow
()
This action method simulates the user clicking the close button by momentarily highlighting the button and then closing the window.
public void performClose
(Object sender)
If the receiver’s delegate or the receiver itself implements windowShouldClose
, then that message is sent with the receiver as the argument. (Only one such message is sent; if both the delegate and the NSWindow implement the method, only the delegate receives the message.) If the windowShouldClose
method returns false
, the window isn’t closed. If it returns true
, or if it isn’t implemented, performClose
invokes the close
method to close the window.
If the receiver doesn’t have a close button or can’t be closed (for example, if the delegate replies false
to a windowShouldClose
message), the system beeps.
public boolean performDragOperation
(NSDraggingInfo aDraggingInfo)
Invoked after the released image has been removed from the screen and the previous prepareForDragOperation
message has returned true
. aDraggingInfo contains details about the dragging operation. This method should do the real work of importing the pasteboard data represented by the image. If the receiver accepts the data, return true
, otherwise return false
.
This action method simulates the user clicking the miniaturize button by momentarily highlighting the button, then miniaturizing the window.
public void performMiniaturize
(Object sender)
If the receiver doesn’t have a miniaturize button or can’t be miniaturized for some reason, the system beeps.
This action method simulates the user clicking the zoom box by momentarily highlighting the button and then zooming the window.
public void performZoom
(Object sender)
If the receiver doesn’t have a zoom box or can’t be zoomed for some reason, the system beeps.
Forwards the message to the global NSApplication object, NSApplication.sharedApplication()
.
public void postEvent
(NSEvent anEvent, boolean flag)
See “NSApplication” for details.
public boolean prepareForDragOperation
(NSDraggingInfo aDraggingInfo)
Invoked when the image is released, if the most recent draggingEntered
or draggingUpdated
message returned an acceptable drag-operation value. aDraggingInfo contains details about the dragging operation. Returns true
if the receiver agrees to perform the drag operation and false
if not.
Returns true
if the window tries to optimize live resize operations by preserving the content of views that have not moved; otherwise, returns false
.
public boolean preservesContentDuringLiveResize
()
When enabled, the window redraws only those views that moved (or do not support this optimization) during a live resize operation.
See preservesContentDuringLiveResize
in NSView for additional information on how to support this optimization.
This action method runs the Print panel, and if the user chooses an option other than canceling, prints the receiver (its frame view and all subviews).
public void print
(Object sender)
Marks the key view loop as dirty and in need of recalculation.
public void recalculateKeyViewLoop
()
The key view loop is actually recalculated the next time someone requests the next or previous key view of the window. The recalculated loop is based on the geometric order of the views in the window.
If you do not want to maintain the key view loop of your window manually, you can use this method to do it for you. When it is first loaded, NSWindow calls this method automatically if your window does not have a key view loop already established. If you add or remove views later, you can call this method manually from your code to update the window’s key view loop. You can also call setAutorecalculatesKeyViewLoop
to have the window recalculate the loop automatically.
Registers pboardTypes as the pasteboard types the receiver will accept as the destination of an image-dragging session.
public void registerForDraggedTypes
(NSArray pboardTypes)
Registering an NSWindow for dragged types automatically makes it a candidate destination object for a dragging session. As such, it must properly implement some or all of the NSDraggingDestination interface methods. As a convenience, NSWindow provides default implementations of these methods. See the “NSDraggingDestination” interface specification for details.
Detaches childWin from the receiver.
public void removeChildWindow
(NSWindow childWin)
Returns the name of the file the receiver represents.
public String representedFilename
()
Invokes discardCursorRects
to clear the receiver’s cursor rectangles, then sends resetCursorRects
to every NSView in the receiver’s view hierarchy.
public void resetCursorRects
()
This method is typically invoked by the NSApplication object when it detects that the key window’s cursor rectangles are invalid. In program code, it’s more efficient to invoke invalidateCursorRectsForView
.
Never invoke this method; it’s invoked automatically when the NSWindow resigns key window status.
public void resignKeyWindow
()
This method sends resignKeyWindow
to the receiver’s first responder, sends windowDidResignKey
to the receiver’s delegate, and posts a WindowDidResignKeyNotification
to the default notification center.
Never invoke this method; it’s invoked automatically when the NSWindow resigns main window status.
public void resignMainWindow
()
This method sends windowDidResignMain
to the receiver’s delegate and posts a WindowDidResignMainNotification
to the default notification center.
Valid only while the receiver is being resized, this method returns the flags field of the event record for the mouse-down event that initiated the resizing session.
public int resizeFlags
()
The integer encodes, as a mask, which of the modifier keys was held down when the event occurred. The flags are listed in NSEvent’s modifierFlags
method description. You can use this method to constrain the direction or amount of resizing. Because of its limited validity, this method should only be invoked from within an implementation of the delegate method windowWillResize
.
Returns the receiver’s resizing increments, which restrict the user’s ability to resize it so that its width and height alter by integral multiples of increments.width
and increments.height
when the user resizes it.
public NSSize resizeIncrements
()
These amounts are whole number values, 1.0 or greater. You can set an NSWindow’s size to any value programmatically.
Splices the receiver’s cached image rectangles, if any, back into its raster image (and buffer if it has one), undoing the effect of any drawing performed within those areas since they were established using cacheImageInRect
.
public void restoreCachedImage
()
You must invoke flushWindow
after this method to guarantee proper redisplay. An NSWindow automatically discards its cached image rectangles when it displays.
The action method for the “Customize Toolbar…” menu item.
public void runToolbarCustomizationPalette
(Object sender)
See the NSToolbar class description for additional information.
Saves the receiver’s frame rectangle in the user defaults system.
public void saveFrameUsingName
(String name)
With the companion method setFrameUsingName
, you can save and reset an NSWindow’s frame over various launchings of an application. The default is owned by the application and stored under the name “NSWindow Frame name.” See the NSUserDefaults class specification for more information.
Returns the screen the receiver is on.
public NSScreen screen
()
If the receiver is partly on one screen and partly on another, the screen where most of it lies is returned. Returns null if the receiver is completely offscreen.
Sends the NSView message nextValidKeyView
to aView, and if that message returns an NSView, invokes makeFirstResponder
with the returned NSView.
public void selectKeyViewFollowingView
(NSView aView)
Sends the NSView message previousValidKeyView
to aView, and if that message returns an NSView, invokes makeFirstResponder
with the returned NSView.
public void selectKeyViewPrecedingView
(NSView aView)
This action method searches for a candidate key view and, if it finds one, invokes makeFirstResponder
to establish it as the first responder.
public void selectNextKeyView
(Object sender)
The candidate is one of the following (searched for in this order):
The current first responder’s next valid key view, as returned by NSView’s nextValidKeyView
method
The object designated as the receiver’s initial first responder (using setInitialFirstResponder
) if it returns true
to an acceptsFirstResponder
message
Otherwise, the initial first responder’s next valid key view, which may end up being null
This action method searches for a candidate key view and, if it finds one, invokes makeFirstResponder
to establish it as the first responder.
public void selectPreviousKeyView
(Object sender)
The candidate is one of the following (searched for in this order):
The current first responder’s previous valid key view, as returned by NSView’s previousValidKeyView
method
The object designated as the receiver’s initial first responder (using setInitialFirstResponder
) if it returns true
to an acceptsFirstResponder
message
Otherwise, the initial first responder’s previous valid key view, which may end up being null
This action method dispatches mouse and keyboard events, specified by theEvent, sent to the receiver by the NSApplication object.
public void sendEvent
(NSEvent theEvent)
Never invoke this method directly. A right mouse-down event in a window of an inactive application is not delivered to NSWindow. It is instead delivered to NSApplications’s sendEvent
with a window number of 0.
Sets whether the receiver accepts mouse-moved events and distributes them to its responders.
public void setAcceptsMouseMovedEvents
(boolean flag)
If flag is true
it does accept them; if flag is false
it doesn’t. NSWindows don’t accept mouse-moved events by default.
Sets whether the receiver can display tool tips even when the application is in the background.
public void setAllowsToolTipsWhenApplicationIsInactive
(boolean allowWhenInactive)
Default is false
. The message does not take effect until the receiver changes to an active state. Note that enabling tool tips in an inactive application will cause the application to do work any time the mouse passes over the window, thus degrading system performance.
Applies windowAlpha to the entire window.
public void setAlphaValue
(float windowAlpha)
Sets the receiver’s size aspect ratio to ratio, constraining the size of its frame rectangle to integral multiples of this size when the user resizes it.
public void setAspectRatio
(NSSize ratio)
An NSWindow’s aspect ratio and its resize increments are mutually exclusive attributes. In fact, setting one attribute cancels the setting of the other. For example, to cancel an established aspect ratio setting for an NSWindow, you send the NSWindow object a setResizeIncrements
message with the width and height set to 1.0.
The setContentAspectRatio
method takes precedence over this method.
Sets whether the receiver automatically displays its views that are marked as needing it.
public void setAutodisplay
(boolean flag)
If flag is true
, views are automatically displayed as needed, typically on each pass through the event loop. If flag is false
, the receiver or its views must be explicitly displayed.
isAutodisplay
displayIfNeeded
displayIfNeeded
(NSView)If flag is true
, the window recalculates the key view loop automatically when views are added or removed.
public void setAutorecalculatesKeyViewLoop
(boolean flag)
If flag is false
, the client code must update the key view loop manually or call recalculateKeyViewLoop
to have the window recalculate it.
Sets the receiver’s background color to aColor.
public void setBackgroundColor
(NSColor aColor)
Sets the receiver’s backing store type to backingType.
public void setBackingType
(int backingType)
The valid backing store types are described in the constants section.
This method can only be used to switch a buffered NSWindow to retained or vice versa; you can’t change the backing type to or from nonretained after initializing an NSWindow (an error is generated if you attempt to do so).
Sets whether the receiver can be hidden during NSApplication’s hide
to flag.
public void setCanHide
(boolean flag)
Sets the aspect ratio of the receiver’s content view to ratio, constraining the dimensions of its content rectangle to integral multiples of that ratio when the user resizes it.
public void setContentAspectRatio
(NSSize ratio)
You can set a window’s content view to any size programmatically, regardless of its aspect ratio. This method takes precedence over setAspectRatio
.
Sets the maximum size of the receiver’s content view to size, which is expressed in the receiver’s base coordinate system.
public void setContentMaxSize
(NSSize size)
The minimum size constraint is enforced for resizing by the user as well as for the setContentSize
method and the setFrame...
methods other than setFrame
. This method takes precedence over setMaxSize
.
Sets the minimum size of the receiver’s content view to size, which is expressed in the receiver’s base coordinate system.
public void setContentMinSize
(NSSize size)
The minimum size constraint is enforced for resizing by the user as well as for the setContentSize
method and the setFrame...
methods other than setFrame
. This method takes precedence over setMinSize
.
Sets the increments for both height and width by which the receiver’s content view can be resized to increments.
public void setContentResizeIncrements
(NSSize increments)
The increments value constrains the width and height of the content rectangle to change by multiples of increments.width
and increments.height
when the user resizes the window. You can set a window’s size to any width and height programmatically. This method takes precedence over setResizeIncrements
.
Sets the size of the receiver’s content view to aSize, which is expressed in the receiver’s base coordinate system.
public void setContentSize
(NSSize aSize)
This size in turn alters the size of the NSWindow itself. Note that the window server limits window sizes to 10,000; if necessary, be sure to limit aSize relative to the frame rectangle.
Makes aView the receiver’s content view; the previous content view is removed from the receiver’s view hierarchy.
public void setContentView
(NSView aView)
The receiver retains the new content view and owns it thereafter. aView is resized to fit precisely within the content area of the NSWindow. You can modify the content view’s coordinate system through its bounds rectangle, but can’t alter its frame rectangle (that is, its size or location) directly.
Makes the key equivalent of aButtonCell the Return (or Enter) key, so when the user presses Return that button performs as if clicked.
public void setDefaultButtonCell
(NSButtonCell aButtonCell)
See the method description for defaultButtonCell
for more information.
Makes anObject the receiver’s delegate, without retaining it.
public void setDelegate
(Object anObject)
An NSWindow’s delegate is inserted in the responder chain after the NSWindow itself and is informed of various actions by the NSWindow through delegation messages.
delegate
tryToPerform
sendActionToTargetFromSender
(NSApplication)Sets the depth limit of the receiver to limit.
public void setDepthLimit
(int limit)
Passing a value of 0 for limit sets the depth limit to the receiver’s default depth limit; using a value of 0 can be useful for reverting an NSWindow to its initial depth.
Sets whether the window context should be updated when the screen profile changes.
public void setDisplaysWhenScreenProfileChanges
(boolean flag)
If flag is false
, the screen profile information for the window context never changes. This is the default setting. If flag is true
, the window context may be changed in the following situations:
A majority of the window is moved to a different screen whose profile is different than the previous screen.
The ColorSync profile of the current screen changes.
After the window context is updated, the window is told to display itself. If you need to update offscreen caches for the window, you should register to receive the WindowDidChangeScreenProfileNotification.
Sets whether the receiver’s document has been edited and not saved to flag.
public void setDocumentEdited
(boolean flag)
NSWindows are in the “not edited” state by default.
You should invoke this method with an argument of true
every time the NSWindow’s document changes in such a way that it needs to be saved and with an argument of false
every time it gets saved. Then, before closing the NSWindow you can use isDocumentEdited
to determine whether to allow the user a chance to save the document.
Sets whether the receiver changes its depth to match the depth of the screen it’s on, or the depth of the deepest screen when it spans multiple screens.
public void setDynamicDepthLimit
(boolean flag)
If flag is true
, the depth limit depends on which screen the receiver is on. If flag is false
, the receiver uses either its preset depth limit or the default depth limit. A different, and nondynamic, depth limit can be set with the setDepthLimit
method.
Sets whether the receiver’s title is omitted from the application’s Windows menu.
public void setExcludedFromWindowsMenu
(boolean flag)
If flag is true
it’s omitted; if flag is false
, it’s listed when it or its miniaturized window is onscreen. The default is false
.
Sets the origin and size of the receiver’s frame rectangle according to frameRect, thereby setting its position and size onscreen, and passes a displayIfNeeded
message down the receiver’s view hierarchy, thus redrawing all NSViews that need to be displayed, if flag is true
.
public void setFrame
(NSRect frameRect, boolean flag)
Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.
If animationFlag is false
, equivalent to the preceding version of this method. Otherwise, if animationFlag is true
, this method performs a smooth resize of the window, where the total time for the resize is specified by animationResizeTime
.
public void setFrame
(NSRect frameRect, boolean displayFlag, boolean animationFlag)
Sets the name used to automatically save the receiver’s frame rectangle in the defaults system to name.
public boolean setFrameAutosaveName
(String name)
If name isn’t the empty string (“”), the receiver’s frame is saved as a user default (as described in saveFrameUsingName
) each time the frame changes. Returns true
if the name is set successfully, false
if it’s being used as an autosave name by another NSWindow in the application (in which case the receiver’s old name remains in effect).
If there is a frame rectangle previously stored for name in the user defaults, the receiver’s frame is set to this frame rectangle. That is, when you call setFrameAutosaveName
with a previously used name, the window picks up the previously saved setting.
Keep in mind that a window controller may change the window’s position when it displays it if window cascading is turned on. To preclude the window controller from changing a window’s position from the one saved in the defaults system, you must send setShouldCascadeWindows:NO
to the window controller.
Sets the receiver’s frame rectangle from the string representation aString, a representation previously creating using stringWithSavedFrame
.
public void setFrameFromString
(String aString)
The frame is constrained according to the receiver’s minimum and maximum size settings. This method causes a windowWillResize
message to be sent to the delegate.
Positions the lower-left corner of the receiver’s frame rectangle at aPoint in screen coordinates.
public void setFrameOrigin
(NSPoint aPoint)
Note that the window server limits window position coordinates to ±16,000.
Positions the top-left corner of the receiver’s frame rectangle at aPoint in screen coordinates.
public void setFrameTopLeftPoint
(NSPoint aPoint)
Note that the window server limits window position coordinates to ±16,000; if necessary, adjust aPoint relative to the window’s lower-left corner to account for this limit.
Sets the receiver’s frame rectangle by reading the rectangle data stored in name from the defaults system.
public boolean setFrameUsingName
(String name)
The frame is constrained according to the receiver’s minimum and maximum size settings. This method causes a windowWillResize
message to be sent to the delegate. Returns true
if name is read and the frame is set successfully; otherwise returns false
.
Sets the receiver’s frame rectangle by reading the rectangle data stored in name from the defaults system. Send this method with force set to true
to use the preceding version of this method on a nonresizable window.
public boolean setFrameUsingName
(String name, boolean force)
Sets whether the receiver has a shadow to hasShadow.
public void setHasShadow
(boolean hasShadow)
If the shadow setting changes, the window shadow is invalidated, forcing the window shadow to be recomputed.
Sets whether the receiver is removed from the screen when the application is inactive.
public void setHidesOnDeactivate
(boolean flag)
If flag is true
, the receiver is hidden (taken out of the screen list) when the application stops being the active application. If flag is false
, the receiver stays onscreen. The default for NSWindow is false
; the default for NSPanel is true
.
Specifies whether the receiver is transparent to mouse clicks and other mouse events, allowing overlay windows.
public void setIgnoresMouseEvents
(boolean flag)
Sets aView as the NSView that’s made first responder (also called the key view) the first time the receiver is placed onscreen.
public void setInitialFirstResponder
(NSView aView)
Sets the receiver’s window level to newLevel.
public void setLevel
(int newLevel)
Some useful predefined values, ordered from lowest to highest, are described in the constants section.
Each level in the list groups windows within it in front of those in all preceding groups. Floating windows, for example, appear in front of all normal-level windows. When a window enters a new level, it’s ordered in front of all its peers in that level.
The constant TornOffMenuWindowLevel
is preferable to its synonym, SubmenuWindowLevel
.
Sets the maximum size to which the receiver’s frame (including its title bar) can be sized to aSize.
public void setMaxSize
(NSSize aSize)
The maximum size constraint is enforced for resizing by the user as well as for the setFrame...
methods other than setFrame
. Note that the window server limits window sizes to 10,000.
The default maximum size of a window is {FLT_MAX, FLT_MAX}
. Once the maximum size of a window has been set, there is no way to reset it other than specifying this default maximum size.
The setContentMaxSize method takes precedence over this method.
Sets the receiver’s custom miniaturized window image to anImage.
public void setMiniwindowImage
(NSImage anImage)
When the user minimizes the window, the dock displays anImage in the corresponding dock tile, scaling it as needed to fit in the tile. If you do not specify a custom image using this method, the dock creates one for you automatically.
You can also call this method as needed to change the miniaturized window image. Typically, you would specify a custom image immediately prior to a window being minimized—when the system posts an WindowWillMiniaturizeNotification
. You can call this method while the window is minimized to update the current image in the dock. However, this method is not recommended for creating complex animations in the dock.
Support for custom images is disabled by default. To enable support, set the AppleDockIconEnabled
key to true
when first registering your application’s user defaults. You must set this key prior to calling the init
method of NSApplication, which reads the current value of the key.
Sets the title of the receiver’s miniaturized counterpart to aString and redisplays it.
public void setMiniwindowTitle
(String aString)
A miniaturized window’s title normally reflects that of its full-size counterpart, abbreviated to fit if necessary. Although this method allows you to set the miniaturized window’s title explicitly, changing the full-size NSWindow’s title (through setTitle
or setTitleWithRepresentedFilename
) automatically changes the miniaturized window’s title as well.
Sets the minimum size to which the receiver’s frame (including its title bar) can be sized to aSize.
public void setMinSize
(NSSize aSize)
The minimum size constraint is enforced for resizing by the user as well as for the setFrame...
methods other than setFrame
.
The setContentMinSize
takes precedence over this method.
Sets whether the receiver is movable by clicking and dragging anywhere in its background.
public void setMovableByWindowBackground
(boolean flag)
A window with a style mask of TexturedBackgroundWindowMask
get set to true
by default. Sheets and drawers cannot be movable by window background.
Sets whether the window device that the receiver manages should be freed when it’s removed from the screen list (and another one created if it’s returned to the screen) to flag.
public void setOneShot
(boolean flag)
Freeing the window device when it’s removed from the screen list can result in memory savings and performance improvement for NSWindows that don’t take long to display. It’s particularly appropriate for NSWindows the user might use once or twice but not display continually. The default is false
.
Sets whether the receiver is opaque to isOpaque.
public void setOpaque
(boolean isOpaque)
For use by subclasses when setting the parent window in the receiver.
public void setParentWindow
(NSWindow window)
You should call super if overriding.
If flag is true
, the window optimizes live resize operations by invalidating only the view contents that changed; this is the default setting.
public void setPreservesContentDuringLiveResize
(boolean flag)
If flag is false
, this optimization is disabled for the window and all of its contained views.
You might consider disabling this optimization for the window if none of the window’s contained views can take advantage of it. Disabling the optimization for the window prevents it from checking each view to see if the optimization is supported.
Sets whether the receiver is merely hidden (false
) or hidden and then released (true
) when it receives a close
message.
public void setReleasedWhenClosed
(boolean flag)
The default for NSWindow is true
; the default for NSPanel is false
. Release when closed, however, is ignored for windows owned by window controllers.
Sets the name of the file the receiver represents to path.
public void setRepresentedFilename
(String path)
Restricts the user’s ability to resize the receiver so the width and height change by multiples of increments.width
and increments.height
as the user resizes the window.
public void setResizeIncrements
(NSSize increments)
The width and height increments should be whole numbers, 1.0 or greater. Whatever the current resize increments, you can set an NSWindow’s size to any height and width programmatically.
Resize increments and aspect ratio are mutually exclusive attributes. For more information, see setAspectRatio
.
The setContentResizeIncrements method takes precedence over this method.
Sets whether the receiver’s resize indicator is visible to show.
public void setShowsResizeIndicator
(boolean show)
This method does not affect whether the receiver is resizable.
If flag is true
, the window title bar is updated to display the standard toolbar button.
public void setShowsToolbarButton
(boolean flag)
If flag is false
, the button is not displayed. If the window does not have a toolbar, this method has no effect.
Sets the string that appears in the receiver’s title bar (if it has one) to aString and displays the title.
public void setTitle
(String aString)
Also sets the title of the receiver’s miniaturized window.
Sets path as the receiver’s title, formatting it as a file-system path, and records path as the receiver’s associated filename using setRepresentedFilename
.
public void setTitleWithRepresentedFilename
(String path)
The filename—not the pathname—is displayed in the receiver’s title bar.
This method also sets the title bar of the receiver’s minimized window.
Sets the receiver’s toolbar to toolbar.
public void setToolbar
(NSToolbar toolbar)
See the NSToolbar class description for additional information.
Sets whether the receiver’s views need display (true
) or do not need display (false
) to flag.
public void setViewsNeedDisplay
(boolean flag)
You should rarely need to invoke this method; NSView’s setNeedsDisplay
and similar methods invoke it automatically.
Set’s the receiver’s window controller to be windowController.
public void setWindowController
(NSWindowController windowController)
Returns whether the receiver’s resize indicator is visible.
public boolean showsResizeIndicator
()
Returns true
if the standard toolbar button is currently displayed; otherwise, returns false
.
public boolean showsToolbarButton
()
Return the given standard button if it is in the window view hierarchy.
public NSButton standardWindowButton
(int button)
Returns a string that represents the receiver’s frame rectangle in a format that can be used with a later setFrameFromString
message.
public String stringWithSavedFrame
()
Returns the receiver’s style mask, indicating what kinds of control items it displays.
public int styleMask
()
See the information about the style mask in the constants section. An NSWindow’s style is set when the object is initialized. Once set, it can’t be changed.
Returns either the string that appears in the title bar of the receiver, or the path to the represented file.
public String title
()
If the title has been set using setTitleWithRepresentedFilename
, then this method returns the file’s path, as described in setTitleWithRepresentedFilename
.
The action method for the “Hide Toolbar” menu item (which alternates with “Show Toolbar”).
public void toggleToolbarShown
(Object sender)
See the NSToolbar class description for additional information.
Returns the receiver’s toolbar.
public NSToolbar toolbar
()
See the NSToolbar class description for additional information.
Dispatches action messages with anObject as the argument.
public boolean tryToPerform
(NSSelector anAction, Object anObject)
The receiver tries to perform the method anAction using its inherited NSResponder method tryToPerform
. If the receiver doesn’t perform anAction, the delegate is given the opportunity to perform it. If either the receiver or its delegate accepts anAction, this method returns
true
; otherwise it returns false
.
Unregisters the receiver as a possible destination for dragging operations.
public void unregisterDraggedTypes
()
Updates the window.
public void update
()
The default implementation of this method does nothing more than post a WindowDidUpdateNotification
to the default notification center. A subclass can override this method to perform specialized operations, but should send an update message to super
just before returning. For example, the NSMenu class implements this method to disable and enable menu commands.
An NSWindow is automatically sent an update
message on every pass through the event loop and before it’s displayed onscreen. You can manually cause an update
message to be sent to all visible NSWindows through NSApplication’s updateWindows
method.
setWindowsNeedUpdate
(NSApplication)updateWindows
(NSApplication)Informs the receiver whether to optimize focusing and drawing when displaying its NSViews.
public void useOptimizedDrawing
(boolean flag)
The optimizations may prevent sibling subviews from being displayed in the correct order—which matters only if the subviews overlap. You should always set flag to true
if there are no overlapping subviews within the NSWindow. The default is false
.
Returns the scale factor applied to the window.
public float userSpaceScaleFactor
()
Clients can multiply view coordinates by the returned scale factor to get a set of new coordinates that are scaled to the resolution of the target screen. For example, if the scale factor is 1.25 and the view frame size is 80 x 80, the actual size of the view frame is 100 x 100 pixels on the target screen.
Searches for an object that responds to a Services request by providing input of sendType and accepting output of returnType.
public Object validRequestorForTypes
(String sendType, String returnType)
Returns that object, or null
if none is found.
Messages to perform this method are initiated by the Services menu. It’s part of the mechanism that passes validRequestorForTypes
messages up the responder chain.
This method works by forwarding the message to the receiver’s delegate if it responds (and provided it isn’t an NSResponder with its own next responder). If the delegate doesn’t respond to the message or returns null
when sent it, this method forwards the message to the NSApplication object. If the NSApplication object returns null
, this method also returns null
. Otherwise this method returns the object returned by the delegate or the NSApplication object.
validRequestorForTypes
(NSResponder)validRequestorForTypes
(NSApplication)Returns true
if any of the receiver’s NSView’s need to be displayed, false
otherwise.
public boolean viewsNeedDisplay
()
Returns the receiver’s window controller.
public Object windowController
()
Returns the window number of the receiver’s window device.
public int windowNumber
()
Each window device in an application is given a unique window number—note that this isn’t the same as the global window number assigned by the window server. This number can be used to identify the window device with the orderWindow
method.
If the receiver doesn’t have a window device, the value returned will be equal to or less than 0.
Returns true
if the receiver is able to receive keyboard and mouse events even when some other window is being run modally, false
otherwise.
public boolean worksWhenModal
()
NSWindow’s implementation of this method returns false
. Only subclasses of NSPanel should override this default.
setWorksWhenModal
(NSPanel)This action method toggles the size and location of the window between its standard state (provided by the application as the “best” size to display the window’s data) and its user state (a new size and location the user may have set by moving or resizing the window).
public void zoom
(Object sender)
For more information on the standard and user states, see windowWillUseStandardFrame
.
The zoom
method is typically invoked after a user clicks the window’s zoom box but may also be invoked programmatically from the performZoom
method. It performs the following steps:
Invokes the windowWillUseStandardFrame
method, if the delegate or the window class implements it, to obtain a “best fit” frame for the window. If neither the delegate nor the window class implements the method, uses a default frame that nearly fills the current screen, which is defined to be the screen containing the largest part of the window’s current frame.
Adjusts the resulting frame, if necessary, to fit on the current screen.
Compares the resulting frame to the current frame to determine whether the window’s standard frame is currently displayed. If the current frame is within a few pixels of the standard frame in size and location, it is considered a match.
Determines a new frame. If the window is currently in the standard state, the new frame represents the user state, saved during a previous zoom. If the window is currently in the user state, the new frame represents the standard state, computed in step 1 above. If there is no saved user state because there has been no previous zoom, the size and location of the window do not change.
Determines whether the window currently allows zooming. By default, zooming is allowed. If the window’s delegate implements the windowShouldZoom
method, zoom
invokes that method. If the delegate doesn’t implement the method but the window does, zoom
invokes the window’s version. windowShouldZoom
returns false
if zooming is not currently allowed.
If the window currently allows zooming, sets the new frame.
These constants specify the presence of a title and various buttons in an NSWindow’s border. Either it can be BorderlessWindowMask
, or it can contain any of the following options, combined using the C bitwise OR operator:
These constants specify how the drawing done in a window is buffered by the window device:
These constants specify the window’s level. The stacking of levels takes precedence over the stacking of windows within each level. That is, even the bottom window in a level will obscure even the top window of the next level down. Levels are listed in order from lowest to highest. These constants are mapped (using #define
) to corresponding elements in the window level enum in Core Graphics.
These constants let you specify how a window is ordered relative to another window. For more information, see orderWindow
.
Constant | Description |
---|---|
Above | Moves the window above the indicated window. |
Below | Moves the window below the indicated window. |
Out | Moves the window off the screen. |
These constants specify the direction a window is currently using to change the key view. They’re used by keyViewSelectionDirection
.
These constants provide a way to access standard title bar widgets:
This constant provides a way to manage scaling factors:
This constant controls the look of a window and its toolbar:
Constant | Description |
---|---|
UnifiedTitleAndToolbarWindowMask | Specifies a window whose toolbar and titlebar are rendered on a single continuous background. Available in Mac OS X v10.4 and later. |
Sent by the default notification center immediately after an NSWindow has become key.
public abstract void windowDidBecomeKey
(NSNotification aNotification)
aNotification is always WindowDidBecomeKeyNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has become main.
public abstract void windowDidBecomeMain
(NSNotification aNotification)
aNotification is always WindowDidBecomeMainNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has changed screens.
public abstract void windowDidChangeScreen
(NSNotification aNotification)
aNotification is always WindowDidChangeScreenNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has changed screen display profiles.
public abstract void windowDidChangeScreenProfile
(NSNotification aNotification)
aNotification is always WindowDidChangeScreenProfileNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has been deminiaturized.
public abstract void windowDidDeminiaturize
(NSNotification aNotification)
aNotification is always WindowDidDeminiaturizeNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow closes a sheet.
public abstract void windowDidEndSheet
(NSNotification aNotification)
aNotification is always WindowDidEndSheetNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has been exposed.
public abstract void windowDidExpose
(NSNotification aNotification)
aNotification is always WindowDidExposeNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has been miniaturized.
public abstract void windowDidMiniaturize
(NSNotification aNotification)
aNotification is always WindowDidMiniaturizeNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has been moved.
public abstract void windowDidMove
(NSNotification aNotification)
aNotification is always WindowDidMoveNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has resigned its status as key window.
public abstract void windowDidResignKey
(NSNotification)
aNotification is always WindowDidResignKeyNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has resigned its status as main window.
public abstract void windowDidResignMain
(NSNotification aNotification)
aNotification is always WindowDidResignMainNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow has been resized.
public abstract void windowDidResize
(NSNotification aNotification)
aNotification is always WindowDidResizeNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately after an NSWindow receives an update
message.
public abstract void windowDidUpdate
(NSNotification aNotification)
aNotification is always WindowDidUpdateNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Invoked when the user attempts to close the window or when the NSWindow receives a performClose
message.
public abstract boolean windowShouldClose
(Object sender)
The delegate can return false
to prevent sender from closing.
This method may not always be called. Specifically, this method is not called when a user quits an application. Additional information on application termination can be found in Graceful Application Termination.
Invoked just before sender is zoomed.
public abstract boolean windowShouldZoom
(NSWindow sender, NSRect newFrame)
Zooming will change the frame of sender to newFrame. The delegate can return false
to prevent sender from zooming.
Sent by the default notification center immediately before an NSWindow opens a sheet.
public abstract void windowWillBeginSheet
(NSNotification aNotification)
aNotification is always WindowWillBeginSheetNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately before an NSWindow closes.
public abstract void windowWillClose
(NSNotification aNotification)
aNotification is always WindowWillCloseNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately before an NSWindow is miniaturized.
public abstract void windowWillMiniaturize
(NSNotification aNotification)
aNotification is always WindowWillMiniaturizeNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent by the default notification center immediately before an NSWindow is moved.
public abstract void windowWillMove
(NSNotification aNotification)
aNotification is always WindowWillMoveNotification
. You can retrieve the NSWindow object in question by sending object
to aNotification.
Sent to the delegate just before the animation of a sheet, giving it the opportunity to return a custom location for the attachment of the sheet (sheet) to the window (window).
public abstract NSRect windowWillPositionSheet
(NSWindow window, NSWindow sheet, NSRect rect)
This method is also invoked whenever the user resizes window while sheet is attached. The default sheet location, passed in rect, is just under the title bar of the window, aligned with the left and right edges of the window.
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 (though genie animation) or is positioned next to it.
Neither the rect parameter nor the returned NSRect 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 zero. 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.
Invoked when sender is being resized (whether by the user or through one of the setFrame...
methods other than setFrame
).
public abstract NSSize windowWillResize
(NSWindow sender, NSSize proposedFrameSize)
proposedFrameSize contains the size (in screen coordinates) the 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. The NSWindow’s minimum and maximum size constraints have already been applied when this method is invoked.
While the user is resizing an NSWindow, the delegate is sent a series of windowWillResize
messages as the NSWindow’s outline is dragged. The NSWindow’s outline is displayed at the constrained size as set by this method.
Invoked when the field editor of sender is requested by anObject.
public abstract Object windowWillReturnFieldEditor
(NSWindow sender, Object anObject)
If the delegate’s implementation of this method returns an object other than null
, the NSWindow substitutes it for the field editor and returns it to anObject.
This method may be called multiple times while a control is first responder. Therefore, you must return the same field editor object for the control while the control is being edited.
Invoked when the undo manager for sender is requested.
public abstract NSUndoManager windowWillReturnUndoManager
(NSWindow sender)
Returns the appropriate undo manager. If this method is not implemented, the NSWindow creates an NSUndoManager for the window.
Invoked by the zoom
method while determining a frame the sender may be zoomed to.
public abstract NSRect windowWillUseStandardFrame
(NSWindow sender, NSRect defaultFrame)
Returns the standard frame (described below) for a window. The defaultFrame parameter passed in is 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.
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.
To customize the standard state, you implement windowWillUseStandardFrame
in the class of the window’s delegate or, if necessary, in a window subclass. Your version should return a suitable standard frame, based on the currently displayed data or other factors.
Posted whenever an NSWindow becomes the key window.
The notification object is the NSWindow that has become key. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow becomes the main window.
The notification object is the NSWindow that has become main. This notification does not contain a userInfo dictionary.
Posted whenever a portion of an NSWindow’s frame moves onto or off of a screen.
The notification object is the NSWindow that has changed screens. This notification does not contain a userInfo dictionary.
This notification is not sent in Mac OS X versions earlier than 10.4.
Posted whenever the display profile for the screen containing the window changes.
This notification is sent only if the window returns true
from displaysWhenScreenProfileChanges
. This notification may be sent when a majority of the window is moved to a different screen (whose profile is also different from the previous screen) or when the ColorSync profile for the current screen changes.
The notification object is the NSWindow whose profile changed. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is deminiaturized.
The notification object is the NSWindow that has been deminiaturized. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow closes an attached sheet.
The notification object is the NSWindow that contained the sheet. This notification does not contain a userInfo dictionary.
Posted whenever a portion of a nonretained NSWindow is exposed, whether by being ordered in front of other windows or by other windows being removed from in front of it.
The notification object is the NSWindow that has been exposed. The userInfo dictionary contains the following information:
Key |
Value |
---|---|
|
The rectangle that has been exposed (NSRect). |
Posted whenever an NSWindow is miniaturized.
The notification object is the NSWindow that has been miniaturized. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is moved.
The notification object is the NSWindow that has moved. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow resigns its status as key window.
The notification object is the NSWindow that has resigned its key window status. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow resigns its status as main window.
The notification object is the NSWindow that has resigned its main window status. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow’s size changes.
The notification object is the NSWindow whose size has changed. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow receives an update
message.
The notification object is the NSWindow that received the update
message. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is about to open a sheet.
The notification object is the NSWindow that is about to open the sheet. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is about to close.
The notification object is the NSWindow that is about to close. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is about to be miniaturized.
The notification object is the NSWindow that is about to be miniaturized. This notification does not contain a userInfo dictionary.
Posted whenever an NSWindow is about to move.
The notification object is the NSWindow that is about to move. This notification does not contain a userInfo dictionary.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)