PATH  Documentation > Mac OS X > Application Kit Reference: Java

Table of Contents

NSWindow


Inherits from:
NSResponder : NSObject
Package:
com.apple.yellow.application

Class at a Glance


An NSWindow manages an on-screen 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.

Principal Attributes


Creation



Interface Builder
Constructor

Commonly Used Methods



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.


Class Description


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 on-screen 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 that the term window sometimes refers to the Application Kit object and sometimes to the Window Server's window device; which meaning is intended is made clear in context. The Application Kit also defines an abstract subclass of NSWindow-NSPanel-that adds behavior more appropriate for auxiliary windows.

You typically set up windows using Interface Builder, which allows you to position them, set up many of their visual and behavioral attributes, and lay out views in them. The programmatic work you do with windows more often involves bringing them on and off the screen; changing dynamic attributes such as the window's title; running modal windows to restrict user input; and assigning a delegate that can monitor certain of the window's actions, such as closing, zooming, and resizing.


Window Anatomy


An NSWindow is defined by a frame rectangle that encloses the entire window, including its title bar, border, and other peripheral elements (such as the resize bar), and by a content rectangle that encloses just its content area. Both rectangles are specified in the screen coordinate system and restricted to integer values. The frame rectangle establishes the NSWindow's base coordinate system. This coordinate system is always aligned with and measured in the same increments as the screen coordinate system (in other words, the base coordinate system can't be rotated or scaled). The origin of the base coordinate system is the bottom-left corner of the NSWindow's frame rectangle.

You create an NSWindow programmatically through one of the constructors by specifying, among other attributes, the size and location of its content rectangle. The frame rectangle is derived from the dimensions of the content rectangle. Various sections below describe other attributes you can specify at initialization and afterward.

When it's created, an NSWindow automatically creates two NSViews: An opaque frame view that fills the frame rectangle and draws the border, title bar, other peripheral elements, and background, and a transparent content view that fills the content rectangle. The frame view and its peripheral elements are private objects that your application can't access directly. The content view is the "highest" accessible NSView in the NSWindow; you can replace the default content view with an NSView of your own creation using the setContentView method. The NSWindow determines the placement of the content view; you can't position it using NSView's setFrame... methods, but must use NSWindow's placement methods, described in "Windows on the Screen" below.

You add other NSViews to the NSWindow as subviews of the content view or as subviews of any of the content view's subviews, and so on, through NSView's addSubview method. This tree of NSViews is called the NSWindow's view hierarchy. When an NSWindow is told to display itself, it does so by sending display... messages to the top-level NSView in its view hierarchy. Because displaying is carried out in a determined order, the content view (which is drawn first) may be wholly or partially obscured by its subviews, and these subviews may be obscured by their subviews (and so on).


Window Styles


The peripheral elements that an NSWindow displays define its style. Though you can't access and manipulate them directly, you can determine at initialization whether an NSWindow has them by providing a style mask to the constructor. There are four possible style elements, specifiable by combining their mask values using the C bitwise OR operator:


Element Mask Value
A title bar TitledWindowMask
A close button ClosableWindowMask
A miniaturize button MiniaturizableWindowMask
A resize bar, border, or box ResizableWindowMask

You can also specify BorderlessWindowMask, in which case none of these style elements is used.


Windows on the Screen


NSWindows can be placed on the screen in three dimensions. Besides horizontal and vertical placement, NSWindows are ordered back-to-front in several distinct levels, which group windows of similar type and purpose so that the more "important" ones appear in front of those less so. (For more information, see the description for setLevel.) Placing an NSWindow on the screen is accomplished with the setFrame method and its variants setFrameOrigin and setFrameTopLeftPoint. Ordering takes place in two ways. The setLevel method puts an NSWindow into a group, such as that for standard windows, floating windows (for example, palettes and some inspector panels), menus, and so on. The orderWindow method orders an NSWindow within its level in front of or in back of another. Convenience methods for ordering include makeKeyAndOrderFront, orderFront and orderBack, as well as orderOut, which removes an NSWindow from the screen. The isVisible method tells whether an NSWindow is on or off the screen. You can also set a window to be removed from the screen automatically when its application isn't active using setHidesOnDeactivate.

NSWindow offers several means of constraining and adjusting window placement:

setMinSize and setMaxSize limit the user's ability to resize the NSWindow (you can still set it to any size programmatically). Similarly, setAspectRatio keeps a window's width and height at the same proportions as the user resizes it, and setResizeIncrements makes the window resize in discrete amounts larger than a single pixel. (Aspect ratio and resize increments are mutually exclusive attributes. See the setAspectRatio and setResizeIncrements method descriptions for more information.)

The constrainFrameRectToScreen method adjusts a proposed frame rectangle so that it lies on the screen in such a way that the user can move and resize a window. Note that any NSWindow with a title bar automatically constrains itself to the screen. The cascadeTopLeftFromPoint method shifts the top left point by an amount that allows one NSWindow to be placed relative to another so that both their title bars are visible.

The zoom method toggles the size and location of a window between its standard state, as determined by the application, and its user state-a new size and location the user may have set by moving or resizing the window.

Finally, the center method places an NSWindow in the most prominent location on the screen, one suitable for important messages and attention panels.

Closely related to window ordering is the idea of opening or closing an NSWindow. Normally, opening is accomplished simply by ordering the NSWindow in front of or in back of another that's on screen. Closing a window involves explicit use of either the close method, which simply removes the NSWindow from the screen, or performClose, which highlights the close button as though the user clicked it. Closing an NSWindow involves at least removing it from the screen but adds the possibility of disposing of it altogether. The setReleasedWhenClosed method sets whether an NSWindow releases itself when it receives a close message. An NSWindow's delegate is also notified when it's about to close, as described in the "Notifications and the NSWindow's Delegate" section.

Miniaturizable windows can be removed from the screen and replaced by a smaller counterpart, whether a freestanding miniwindow or a button in the task bar. The miniaturize and deminiaturize methods reduce and reconstitute an NSWindow, and performMiniaturize simulates the user clicking the NSWindow's miniaturize button. You can also set the image and title displayed in a freestanding miniwindow by sending setMiniwindowImage and setMiniwindowTitle messages to the NSWindow object.

An NSWindow can store its placement in the user defaults system, so that it appears in the same location the next time the user starts the application. The saveFrameUsingName method stores the frame rectangle, and setFrameUsingName sets it from the value in user defaults. You can also use the setFrameAutosaveName method to have an NSWindow save the frame rectangle any time it changes. To expunge a frame rectangle from the defaults system, use the class method removeFrameUsingName.


Titles and Represented Files


A titled NSWindow can display an arbitrary title or one derived from a filename. The setTitle method puts an arbitrary string on the title bar. The setTitleWithRepresentedFilename method formats a filename in the title bar in a readable format and associates the NSWindow with that file. You can set the associated file without changing the title using setRepresentedFilename. You can use the association between the NSWindow and the file in any way you see fit. One convenience offered by NSWindow is marking the file as being edited, so that you can prompt the user to save it on closing the window. The method for marking this is setDocumentEdited. When the window closes, its delegate can check it with isDocumentEdited to see whether the document needs to be saved.

Most applications include a submenu that displays the titles of windows, called the Windows menu. This submenu automatically lists windows that have a title bar and are resizable and that can become the main window (as described under "Event Handling" ). When you change an NSWindow's title, this change is also automatically reflected in the Windows menu. You can exclude a window that would otherwise be listed by sending it a setExcludedFromWindowsMenu message.


Window Device Attributes


Nearly every NSWindow has a corresponding window device in the Window Server. The window device holds the NSWindow's drawn image, and has two attributes determined by the Window Server and five attributes that the NSWindow controls. The Window Server assigns the window device a unique identifier (within an application). This is the window number, and it's returned by the windowNumber method. Each window also has a graphics state that most NSViews share for drawing (NSViews can create their own as well). The gState method returns its identifier. The five attributes under direct NSWindow control are:

A window device's backing store type is set when the NSWindow is initialized and can be one of three types. A buffered window device renders all drawing into a display buffer and then flushes it to the screen. Always drawing to the buffer produces very smooth display, but can require significant amounts of memory. Buffered windows are best for displaying material that must be redrawn often, such as text. A retained window device also uses a buffer, but draws directly to the screen where possible and to the buffer for any portions that are obscured. A nonretained window device has no buffer at all, and must redraw portions as they're exposed. Further, this redrawing is suspended when the NSWindow's display mechanism is preempted. For example, if the user drags a window across a nonretained window, the nonretained window is "erased" and isn't redrawn until the user releases the mouse. Both retained and nonretained windows are also subject to a flashing effect as individual drawing operations are performed, but their results do get to the screen more quickly than those of buffered windows. You can change the backing store type between buffered and retained after initialization using the setBackingType method.

The defer argument to the constructor specifies whether the NSWindow creates its window device immediately or only when it's moved on screen. Deferring creation of the window device can offer some performance gain for windows that aren't displayed immediately because it reduces the amount of work that needs to be performed up front. Deferring creation of the window device is particularly useful when creation of the NSWindow itself can't be deferred or when an NSWindow is needed for purposes other than displaying content. Submenus with key equivalents, for example, must exist for the key equivalents to work, but may never actually be displayed.

Memory can also be saved by destroying the window device when the window is removed from the screen. The setOneShot method controls this behavior. One-shot window devices exist only when their NSWindows are on screen.

Like the display hardware, a window device's buffer has a depth, or a limit to the memory allotted each pixel. Buffered and retained windows start out with a default window depth of 2 bits per pixel, and this depth grows to the window device's limit as the NSWindow draws richer images (more shades of gray, more colors). A window device's depth is set using the setDepthLimit method, which takes as an argument a window depth limit created using the BestDepth function.

If an NSWindow draws color into its buffer and there's a color screen available, the Window Server automatically promotes the window's depth (up to its limit). This happens whether or not the window is actually on a color screen; similarly, if the user drags a window that displays color from a color screen to a monochrome screen, it remains at its richer depth. In both cases, the window's depth is greater than the screen can properly display. Keeping a window's depth at its richest preserves the displayed image, but it may produce undesired results such as dithering on a more limited screen and does causes slight performance reduction when the window buffer is deeper than the screen requires. You can set an NSWindow to keep its depth at the limit of the screen it's on with the setDynamicDepthLimit method. When it's moved to a new screen, a window with a dynamic depth limit is redrawn into the newly adjusted buffer. Making a window's depth limit dynamic overrides the limit set using setDepthLimit, and removing the dynamic limit reverts the static limit to the default.


Window Display and Updating


Display of an NSWindow begins with the drawing performed by its view objects, which accumulates in the window's display buffer or appears immediately on the screen. NSWindows, like NSViews, can be displayed unconditionally or merely marked as needing display, using the display and setViewsNeedDisplay methods, respectively. A displayIfNeeded message causes the NSWindow's views to display only if they've been marked as needing display. Normally, any time an NSView is marked as needing display, the NSWindow makes note of this fact and automatically displays itself shortly after. This automatic display is typically performed on each pass through the event loop, but can be turned off using the setAutodisplay method. If you turn off autodisplay for an NSWindow, you're then responsible for displaying it whenever necessary.

A related mechanism is that of updating. On each pass through the event loop, the application object invokes its updateWindows method, which sends an update message to each NSWindow. Subclasses of NSWindow can override this method to examine the state of the application and change their own state or appearance accordingly-enabling or disabling menus, buttons, and other controls based on the object that's selected, for example.

In addition to displaying itself on the screen, an NSWindow can print itself in its entirety, just as an NSView can. The print method runs the application's Print panel and causes the NSWindow's frame view to print itself. The dataWithEPSInsideRect method behaves similarly. See the NSView class specification for more information on printing.


Event Handling


As described in the NSResponder class specification, most events coming into an application make their way to an NSWindow in a sendEvent message. A key event is directed at the key window, while a mouse event is directed at whatever window lies under the cursor. If an event affects the window directly-resizing or moving it, for example-it performs the appropriate operation itself and sends messages to its delegate informing it of its intentions, thus allowing your application to intercede. The window sends other events up its responder chain from the appropriate starting point: the first responder for a key event, the view under the cursor for a mouse event. These events are then typically handled by some view object in the window. See the NSView and NSEvent class specifications for more information on how to intercept and handle events.

The following sections describe aspects of events not directly related to handling individual events. These include changing the key and main windows, changing the first responder by keyboard rather than mouse actions, sharing a single text object for lightweight editing tasks, and running a modal event loop around an entire window rather than a single view object.


Changing the Key and Main Windows


Windows already on screen automatically change their status as the key or main window based on the user's actions with the mouse and on how the clicked view handles the mouse event. You can also set the key and main windows programmatically by sending the relevant window object a makeKeyWindow or makeMainWindow message. Setting the key and main windows programmatically is particularly useful when creating a new window. Because making a window key is often combined with ordering the window to the front of the screen, NSWindow defines a convenience method, makeKeyAndOrderFront, that performs both operations.

Not all windows are suitable for acting as the key or main window. For example, a window that merely displays information, and contains no objects that need to respond to events or action messages, can completely forgo ever becoming the key window. Similarly, a window that acts as a floating palette of items that are only dragged out by mouse actions never needs to be the key window. Such a window can be defined as a subclass of NSWindow that overrides the methods canBecomeKeyWindow and canBecomeMainWindow to return false instead of the default of true. Defining a window in this way prevents it from ever becoming the key or main window. Though NSWindow defines these methods, typically only subclasses of NSPanel refuse to accept key or main window status.


Keyboard Interface Control


A window's first responder is often a view object selected by the user clicking it. For text fields and other view objects (mainly subclasses of NSControl), the user can select the first responder with the keyboard using the Tab and Shift keys. NSView defines the methods for setting up and examining the loop of objects that the user can select in this manner. A view that's the first responder is called the key view, and the views that can become the key view in a window are linked together in the window's key view loop. You normally set up the key view loop using Interface Builder, establishing connections between the nextKeyView outlets of views in the window and setting the window's initialFirstResponder outlet to the view that you want selected when the window is first placed on screen. If you do not set this outlet, the window sets a key loop (not necessarily the same as the one you would have specified!) and picks a default initial first responder for you.

In addition to the key view loop, a window can have a default button cell, which uses the Return (or Enter) key as its key equivalent. The setDefaultButtonCell method establishes this button cell; you can also set it in Interface Builder by setting a button cell's key equivalent to '\r'. The default button cell draws itself as a focal element for keyboard interface control unless another button cell is focused on. In this case, it temporarily draws itself as normal and disables its key equivalent. Another default key established by NSWindow is the Escape key, which immediately aborts a modal loop (described below under "Modal Windows" ).

See the NSResponder class specification for more information on keyboard interface control.


The Field Editor


Each NSWindow has a text object that is shared for light editing tasks. This object, the window's field editor, is inserted in the view hierarchy when an object needs to edit some text and removed when the object is finished. The field editor is used by NSTextFields and other controls, for example, to edit the text that they display. The fieldEditorForObject method returns a window's field editor, after asking the delegate for a substitute using windowWillReturnFieldEditor. You can override the NSWindow method in subclasses or provide a delegate to substitute a class of text object different from the default of NSTextView, thereby customizing text editing in your application.


Modal Windows


You can make a whole window or panel run in modal fashion, using the application's normal event loop machinery but restricting input to the modal window or panel. Modal operation is useful for windows and panels that require the user's attention before an action can proceed. Examples include error messages and warnings, as well as operations that require input, such as printing or saving a document.

There are two mechanisms for operating a modal window or panel. The first, and simpler, is to invoke NSApplication's runModalForWindow method, which monopolizes events for the specified window until one of the NSApplication methods stopModal, abortModal, or stopModalWithCode is invoked, typically by a button's action method. The stopModal method ends the modal status of the window or panel from within the event loop. It doesn't work if invoked from a method invoked by a timer or by a distributed object because those mechanisms operate outside of the event loop. To terminate the modal loop in these situations, you can use abortModal. The stopModal method is typically invoked when the user clicks the OK button (or equivalent), abortModal when the user clicks the Cancel button (or presses the Escape key). These two methods are equivalent to stopModalWithCode with the appropriate argument. See the method descriptions in the NSApplication class specification for more information.

The second mechanism for operating a modal window or panel, called a modal session, allows the application to perform a long operation while it still sends events to the window or panel. Modal sessions are particularly useful for panels that allow the user to cancel or modify an operation. To begin a modal session, invoke NSApplication's beginModalSessionForWindow method, which sets the window up for the session and returns an identifier used for other session-controlling methods. At this point, the application can run in a loop that performs the operation, on each pass sending runModalSession to the application object so that pending events can be dispatched to the modal window. This method returns a code indicating whether the operation should continue, stop, or abort, which is typically established by the methods described above for runModalForWindow. After the loop concludes, you can remove the window from the screen and invoke NSApplication's endModalSession method to restore the normal event loop. The method description for runModalForWindow in the NSApplication class specification includes sample code illustrating a modal session.


Note: You can write a modal event loop for a view object so that the object has access to all events pertaining to a particular task, such as tracking the mouse in the view. For an example, see "Mouse Events" in the class specification for NSView.

The normal behavior of a modal window or session is to exclude all other windows and panels from receiving events. For windows and panels that serve as general auxiliary controls, such as menus and the Font panel, this behavior is overly restrictive. The user must be able to use menu key equivalents (such as those for Cut and for Paste) and change the font of text in the modal window, and this requires that nonmodal panels be able to receive events. To support this behavior, an NSWindow subclass overrides the worksWhenModal method to return true. This allows the window to receive mouse and keyboard events even when a modal window is present. If a subclass needs to work when a modal window is present, it should usually be a subclass of NSPanel, not of NSWindow.

Modal windows and modal sessions provide different levels of control to the application and the user. Modal windows restrict all action to the window itself and any methods invoked from the window. Modal sessions allow the application to continue an operation while accepting input only through the modal session window. Beyond this, you can use distributed objects to perform background operations in a separate thread, while allowing the user to perform other actions with any part of the application. The background thread can communicate with the main thread, allowing the application to display the status of the operation in a nonmodal panel, perhaps including controls to stop or affect the operation as it occurs. Note that because the Application Kit isn't thread-safe, the background thread should communicate with a designated object in the main thread that in turn interacts with the Application Kit.


Notifications and the NSWindow's Delegate


NSWindow offers observers a rich set of notifications, which it broadcasts on such occurrences as gaining or losing key or main window status, miniaturizing, moving or resizing, becoming exposed, and closing. Each notification is matched to a delegate method, so an NSWindow's delegate is automatically registered for all notifications that it has methods for. NSWindow also offers its delegate a few other methods, such as windowShouldClose, which requests approval to close, windowWillResize, which allows the delegate to constrain the NSWindow's size, windowWillUseStandardFrame, which allows the delegate to set the window frame for zooming, and windowWillReturnFieldEditor, which gives the delegate a chance to modify the field editor or substitute a different editor. See the individual notification and delegate method descriptions for more information.


Other Features


NSWindow defines a number of methods to assist its view objects in certain operations that may extend in scope beyond a single view or even outside the window containing them. One of these operations is image dragging. Although most dragging operations are initiated by and occur between view objects, NSWindow also defines an image-dragging method, dragImage. An NSWindow can also serve as the destination for dragging operations, registering the types it accepts with registerForDraggedTypes and unregisterDraggedTypes.

NSView provides methods for adding, removing, discarding, and resetting cursor rectangles-areas where the cursor image changes when the mouse enters them. NSWindow overrides some of these methods and provides additional methods for working with cursor rectangles. For example, an NSWindow can:

Finally, to support transitory drawing by NSViews, NSWindow declares methods that temporarily cache a portion of its raster image so that it can be restored later. This feature is useful for situations where highly dynamic drawing must be done over the otherwise static image of the window. For example, in a drawing program where the user drags lines and other shapes directly onto a canvas, it's more efficient to restore the window's cached image and draw anew over that than to have all of the view objects send rendering instructions to the Window Server. For more information, see the method descriptions for cacheImageInRect, restoreCachedImage, and discardCachedImage.




Constants


styleMask specifies the receiver's style. It can either be BorderlessWindowMask, or it can contain any of the following options, combined using the C bitwise OR operator:


Constant Description
BorderlessWindowMask The NSWindow displays none of the usual peripheral elements. Useful only for display or caching purposes.
TitledWindowMask The NSWindow displays a title bar.
ClosableWindowMask The NSWindow displays a close button.
MiniaturizableWindowMask The NSWindow displays a miniaturize button.
ResizableWindowMask The NSWindow displays a resize bar or border.

These constants specify how the drawing done in a window is buffered by the window device


Constant Description
Buffered Description forthcoming.
Retained Description forthcoming.
Nonretained Description forthcoming.

These constants specify the window's level


Constant Description
NormalWindowLevel The default level for NSWindow objects.
FloatingWindowLevel Useful for floating palettes.
SubmenuWindowLevel Reserved for submenus. Synonymous with TornOffMenuWindowLevel.
TornOffMenuWindowLevel The level for a torn-off menu. Synonymous with SubmenuWindowLevel.
MainMenuWindowLevel Reserved for the application's main menu.
ModalPanelWindowLevel The level for a modal panel.
PopUpMenuWindowLevel The level for a popup menu.
ScreenSaverWindowLevel Description forthcoming.

These constants let you specify how a window is ordered relative to another window. For more information, see orderWindow.


Constant Description
Above Description forthcoming.
Below Description forthcoming.
Out Description forthcoming.

These constants specify the direction a window is currently using to change the key view. It's used by keyViewSelectionDirection:


Constant Description
DirectSelection The receiver isn't traversing the key view loop.
SelectingNext The receiver is proceeding to the next valid key view.
SelectingPrevious The receiver is proceeding to the previous valid key view.



Method Types


Constructors
NSWindow
Calculating layout
contentRectForFrameRect
frameRectForContentRect
minFrameWidthWithTitle
Converting coordinates
convertBaseToScreen
convertScreenToBase
Moving and resizing
setFrame
frame
setFrameOrigin
setFrameTopLeftPoint
setContentSize
cascadeTopLeftFromPoint
center
resizeFlags
performZoom
zoom
Constraining window size
maxSize
minSize
setMaxSize
setMinSize
setAspectRatio
aspectRatio
setResizeIncrements
resizeIncrements
constrainFrameRectToScreen
Saving the frame to user defaults
removeFrameUsingName
saveFrameUsingName
setFrameUsingName
setFrameAutosaveName
frameAutosaveName
setFrameFromString
stringWithSavedFrame
Ordering windows
orderBack
orderFront
orderFrontRegardless
orderOut
orderWindow
setLevel
level
isVisible
Making key and main windows
becomeKeyWindow
canBecomeKeyWindow
isKeyWindow
makeKeyAndOrderFront
makeKeyWindow
resignKeyWindow
becomeMainWindow
canBecomeMainWindow
isMainWindow
makeMainWindow
resignMainWindow
Working with the default button
defaultButtonCell
setDefaultButtonCell
disableKeyEquivalentForDefaultButtonCell
enableKeyEquivalentForDefaultButtonCell
Display and drawing
display
displayIfNeeded
setViewsNeedDisplay
viewsNeedDisplay
useOptimizedDrawing
setAutodisplay
isAutodisplay
update
Flushing graphics
flushWindow
flushWindowIfNeeded
enableFlushWindow
disableFlushWindow
isFlushWindowDisabled
Bracketing temporary drawing
cacheImageInRect
restoreCachedImage
discardCachedImage
Window Server information
windowNumber
gState
deviceDescription
setBackingType
backingType
setOneShot
isOneShot
defaultDepthLimit
setDepthLimit
depthLimit
setDynamicDepthLimit
hasDynamicDepthLimit
canStoreColor
Screen information
deepestScreen
screen
Working with the responder chain
makeFirstResponder
firstResponder
Event handling
currentEvent
nextEventMatchingMask
discardEventsMatchingMask
postEvent
sendEvent
tryToPerform
keyDown
mouseLocationOutsideOfEventStream
setAcceptsMouseMovedEvents
acceptsMouseMovedEvents
Working with the field editor
fieldEditorForObject
endEditingForObject
Keyboard interface control
setInitialFirstResponder
initialFirstResponder
selectKeyViewFollowingView
selectKeyViewPrecedingView
selectNextKeyView
selectPreviousKeyView
keyViewSelectionDirection
Setting the title and filename
setTitle
setTitleWithRepresentedFilename
title
setRepresentedFilename
representedFilename
Marking a window edited
setDocumentEdited
isDocumentEdited
Closing the window
close
performClose
setReleasedWhenClosed
isReleasedWhenClosed
Miniaturizing and miniwindows
miniaturize
performMiniaturize
deminiaturize
isMiniaturized
setMiniwindowImage
miniwindowImage
setMiniwindowTitle
miniwindowTitle
Working with menus
menuChanged
Working with the Windows menu
setExcludedFromWindowsMenu
isExcludedFromWindowsMenu
Working with cursor rectangles
areCursorRectsEnabled
enableCursorRects
disableCursorRects
discardCursorRects
invalidateCursorRectsForView
resetCursorRects
Dragging
concludeDragOperation
dragImage
draggingEntered
draggingExited
draggingUpdated
performDragOperation
prepareForDragOperation
registerForDraggedTypes
unregisterDraggedTypes
Controlling behavior
setHidesOnDeactivate
hidesOnDeactivate
worksWhenModal
Setting the content view
setContentView
contentView
Setting the background color
setBackgroundColor
backgroundColor
Getting the style mask
styleMask
Working with Services
validRequestorForTypes
Printing and faxing
print
dataWithEPSInsideRect
dataWithPDFInsideRect
Setting the delegate
setDelegate
delegate


Constructors



NSWindow

public NSWindow()

Description forthcoming.

public NSWindow( NSRect contentRect, int styleMask, int backingType, boolean defer)

Creates a new NSWindow object, whose content rectangle is specified relative to the lower-left corner of the main screen

contentRect 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.

styleMask specifies the receiver's style. It can either be NSBorderlessWindowMask, or it can contain any of the options described in "Constants" , 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.

backingType specifies how the drawing done in the receiver is buffered by the object's window device, and possible values are described in "Constants" .

defer 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 on screen. All display messages sent to the NSWindow or its NSViews are postponed until the window is created, just before it's moved on screen. 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.

public NSWindow( NSRect contentRect, int styleMask, int bufferingType, boolean defer, NSScreen aScreen)

Creates an NSWindow object, whose content rectangle is specified relative to the lower-left corner of aScreen. Otherwise this method is equivalent to the other 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.

See Also: orderFront, setTitle, setOneShot




Static Methods



contentRectForFrameRect

public static NSRect contentRectForFrameRect( NSRect frameRect, int aStyle)

Returns the content rectangle used by an NSWindow with a frame rectangle of frameRect and a style mask of aStyle. Both frameRect and the returned content rectangle are expressed in screen coordinates. See "Constants" for a list of style mask values.

See Also: frameRectForContentRect



defaultDepthLimit

public static int defaultDepthLimit()

Returns the default depth limit for instances of NSWindow. This is determined by the depth of the deepest screen level available to the window server.

The value returned can be examined with the Application Kit functions PlanarFromDepth, ColorSpaceFromDepth, BitsPerSampleFromDepth, BitsPerPixelFromDepth.

See Also: setDepthLimit, setDynamicDepthLimit, canStoreColor



frameRectForContentRect

public static NSRect frameRectForContentRect( NSRect contentRect, int aStyle)

Returns the frame rectangle used by an NSWindow with a content rectangle of contentRect and a style mask of aStyle. Both contentRect and the returned frame rectangle are expressed in screen coordinates. See "Constants" for a list of style mask values.

See Also: contentRectForFrameRect



menuChanged

public static void menuChanged(NSMenu aMenu)

This method does nothing; it is here for backwards compatibility.

See Also: menu (NSResponder)



minFrameWidthWithTitle

public static float minFrameWidthWithTitle( String aTitle, int aStyle)

Returns the minimum width an NSWindow's frame rectangle must have for it to display all of aTitle, given aStyle as its style mask. See "Constants" for a list of acceptable style mask values.

removeFrameUsingName

public static void removeFrameUsingName(String name)

Removes the frame data stored under name from the application's user defaults.

See Also: setFrameUsingName, setFrameAutosaveName




Instance Methods



acceptsMouseMovedEvents

public boolean acceptsMouseMovedEvents()

Returns true if the receiver accepts and distributes mouse-moved events, false if it doesn't. NSWindows by default don't accept mouse-moved events.

See Also: setAcceptsMouseMovedEvents



areCursorRectsEnabled

public boolean areCursorRectsEnabled()

Returns true if the receiver's cursor rectangles are enabled, false if they're not.

See Also: enableCursorRects, addCursorRect (NSView)



aspectRatio

public NSSize aspectRatio()

Returns the receiver's size aspect ratio. 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.

See Also: resizeIncrements, setAspectRatio, setFrame



backgroundColor

public NSColor backgroundColor()

Returns the color of the receiver's background.

See Also: setBackgroundColor



backingType

public int backingType()

Returns the receiver's backing store type. The possible return values are described in "Constants" .

See Also: setBackingType



becomeKeyWindow

public void becomeKeyWindow()

Invoked automatically to inform the receiver that it has become the key window; never invoke this method directly. 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.

See Also: makeKeyWindow, makeKeyAndOrderFront, becomeMainWindow



becomeMainWindow

public void becomeMainWindow()

Invoked automatically to inform the receiver that it has become the main window; never invoke this method directly. This method posts a WindowDidBecomeMainNotification to the default notification center.

See Also: makeMainWindow, becomeKeyWindow



cacheImageInRect

public void cacheImageInRect(NSRect aRect)

Stores the receiver's raster image from aRect, which is expressed in the receiver's base coordinate system. This 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.

See Also: display



canBecomeKeyWindow

public boolean canBecomeKeyWindow()

Returns true if the receiver can become the key window, false if it can't. 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.

See Also: isKeyWindow, makeKeyWindow



canBecomeMainWindow

public boolean canBecomeMainWindow()

Returns true if the receiver can become the main window, false if it can't. 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.

See Also: isMainWindow, makeMainWindow



canStoreColor

public boolean canStoreColor()

Returns true if the receiver has a depth limit that allows it to store color values, false if it doesn't.

See Also: depthLimit, shouldDrawColor (NSView)



cascadeTopLeftFromPoint

public NSPoint cascadeTopLeftFromPoint(NSPoint topLeftPoint)

Returns a point shifted from topLeftPoint that can be used to place the receiver in a cascade relative to another NSWindow positioned at topLeftPoint, so the title bars of both NSWindows are fully visible. Both points are expressed in screen coordinates.

See Also: setFrameTopLeftPoint



center

public void center()

Sets the receiver's location to the center of the screen. 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 on screen, however; use makeKeyAndOrderFront to do that.

You typically use this method to place an NSWindow-most likely an attention panel-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.



close

public void close()

Removes the receiver from the screen.

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:

Use performClose if you need these features.

See Also: orderOut



concludeDragOperation

public void concludeDragOperation(NSDraggingInfo draggingInfo)

Description forthcoming.

constrainFrameRectToScreen

public NSRect constrainFrameRectToScreen( NSRect frameRect, NSScreen aScreen)

Modifies and returns frameRect so that its top edge lies on aScreen. If the receiver is resizable, the rectangle's height is adjusted to bring the bottom edge onto 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 on screen and whenever its size is changed.

Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.



contentView

public NSView contentView()

Returns the receivers's content view, the highest accessible NSView object in the receiver's view hierarchy.

See Also: setContentView



convertBaseToScreen

public NSPoint convertBaseToScreen(NSPoint aPoint)

Returns aPoint converted from the receiver's base coordinate system to the screen coordinate system.

See Also: convertScreenToBase, convertPointToView (NSView)



convertScreenToBase

public NSPoint convertScreenToBase(NSPoint aPoint)

Returns aPoint converted from the screen coordinate system to the receiver's base coordinate system.

See Also: convertBaseToScreen, convertRectFromView (NSView)



currentEvent

public NSEvent currentEvent()

Returns the event currently being processed by the application, by invoking NSApplication's currentEvent method.

dataWithEPSInsideRect

public NSData dataWithEPSInsideRect(NSRect aRect)

Returns EPS data that draws the region of the receiver within aRect (expressed in the receiver's base coordinate system). This data can be placed on a pasteboard, written to a file, or used to create an NSImage object.

See Also: dataWithEPSInsideRect (NSView), writeEPSInsideRectToPasteboard (NSView)



dataWithPDFInsideRect

public NSData dataWithPDFInsideRect(NSRect aRect)

Returns PDF data that draws the region of the receiver within aRect (expressed in the receiver's base coordinate system). This data can be placed on a pasteboard, written to a file, or used to create an NSImage object.

See Also: dataWithPDFInsideRect (NSView), writePDFInsideRectToPasteboard (NSView)



deepestScreen

public NSScreen deepestScreen()

Returns the deepest screen the receiver is on (it may be split over several screens), or null if the receiver is off screen.

See Also: screen



defaultButtonCell

public NSButtonCell defaultButtonCell()

Returns the button cell that performs as if clicked when the NSWindow receives a Return (or Enter) key event. 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.

See Also: setDefaultButtonCell, disableKeyEquivalentForDefaultButtonCell, enableKeyEquivalentForDefaultButtonCell



delegate

public Object delegate()

Returns the receiver's delegate, or null if it doesn't have a delegate.

See Also: setDelegate



deminiaturize

public void deminiaturize(Object sender)

Deminiaturizes the receiver. You rarely need to invoke this method; it's invoked automatically when an NSWindow is deminiaturized by the user.

See Also: miniaturize, styleMask



depthLimit

public int depthLimit()

Returns the depth limit of the receiver. The value returned can be examined with the Application Kit functions PlanarFromDepth, ColorSpaceFromDepth, BitsPerSampleFromDepth, BitsPerPixelFromDepth.

See Also: defaultDepthLimit, setDepthLimit, setDynamicDepthLimit



deviceDescription

public NSDictionary deviceDescription()

Returns a dictionary containing information about the receiver's resolution, color depth, and so on. This information is useful for tuning images and colors to the window's display capabilities. The contents of the dictionary are:
Dictionary Key Value
DeviceResolution An NSValue containing a value of type NSSize that describe the receiver's raster resolution in dots per inch (dpi).
DeviceColorSpaceName A String giving the name of the receiver's color space. See the NSGraphics Constants section for a list of possible values.
DeviceBitsPerSample A Number containing an integer that gives the bit depth of the receiver's raster image (2-bit, 8-bit, and so forth).
DeviceIsScreen true, indicating that the receiver displays on the screen.
DeviceSize An NSValue containing a value of type NSSize that gives the size of the receiver's frame rectangle.

See Also: deviceDescription (NSScreen), bestRepresentationForDevice (NSImage), colorUsingColorSpaceName (NSColor)



disableCursorRects

public void disableCursorRects()

Disables all cursor rectangle management within the receiver. Use this method when you need to do some special cursor manipulation and you don't want the Application Kit interfering.

See Also: enableCursorRects



disableFlushWindow

public void disableFlushWindow()

Disables the flushWindow method for the receiver. 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 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.



disableKeyEquivalentForDefaultButtonCell

public void disableKeyEquivalentForDefaultButtonCell()

Disables the default button cell's key equivalent, so it doesn't perform a click when the user presses Return (or Enter). See the method description for defaultButtonCell for more information.

See Also: enableKeyEquivalentForDefaultButtonCell



discardCachedImage

public void discardCachedImage()

Discards all of the receiver's cached image rectangles. An NSWindow automatically discards its cached image rectangles when it displays.

See Also: cacheImageInRect, restoreCachedImage, display



discardCursorRects

public void discardCursorRects()

Invalidates all cursor rectangles in the receiver. 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.

discardEventsMatchingMask

public void discardEventsMatchingMask( int mask, NSEvent lastEvent)

Forwards the message to the NSApplication object, which handles it as described in the NSApplication class specification.

display

public void display()

Passes a display message down the receiver's view hierarchy, thus redrawing all NSViews within the receiver, including the frame view which draws the border, title bar, and other peripheral elements.

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.

See Also: display (NSView), displayIfNeeded, isAutodisplay



displayIfNeeded

public void displayIfNeeded()

Passes a displayIfNeeded message down the receiver's view hierarchy, thus redrawing all NSViews that need to be displayed, including the frame view which draws the border, title bar, and other peripheral elements. 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.

See Also: display, displayIfNeeded (NSView), setNeedsDisplay (NSView), isAutodisplay



dragImage

public void dragImage( NSImage anImage, NSPoint aPoint, NSSize initialOffset, NSEvent theEvent, NSPasteboard pboard, Object sourceObject, boolean slideBack)

Begins a dragging session. This method should be invoked only from within a view's implementation of the mouseDown method (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 this method in the NSView class specification for more information.

draggingEntered

public int draggingEntered(NSDraggingInfo draggingInfo)

Description forthcoming.

draggingExited

public void draggingExited(NSDraggingInfo draggingInfo)

Description forthcoming.

draggingUpdated

public int draggingUpdated(NSDraggingInfo draggingInfo)

Description forthcoming.

enableCursorRects

public void enableCursorRects()

Reenables cursor rectangle management within the receiver after a disableCursorRects message.

enableFlushWindow

public void enableFlushWindow()

Reenables the flushWindow method for the receiver after it was disabled through a previous disableFlushWindow message.

enableKeyEquivalentForDefaultButtonCell

public void enableKeyEquivalentForDefaultButtonCell()

Reenables the default button cell's key equivalent, so it performs a click when the user presses Return (or Enter). See the method description for defaultButtonCell for more information.

See Also: disableKeyEquivalentForDefaultButtonCell



endEditingForObject

public void endEditingForObject(Object anObject)

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. If the field editor is the first responder, it's made to resign that status even if its resignFirstResponder method returns false. This 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.

See Also: fieldEditorForObject, windowWillReturnFieldEditor



fieldEditorForObject

public NSText fieldEditorForObject( boolean createFlag, Object anObject)

Returns the receiver's field editor, creating it if needed if createFlag is true. 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 provided as a convenience and 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 NSText 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:



firstResponder

public NSResponder firstResponder()

Returns the receiver's first responder.

See Also: makeFirstResponder, acceptsFirstResponder (NSResponder)



flushWindow

public void flushWindow()

Flushes the receiver's off-screen buffer to the screen if the receiver is buffered and flushing is enabled. 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.

See Also: flushWindowIfNeeded, disableFlushWindow, enableFlushWindow



flushWindowIfNeeded

public void flushWindowIfNeeded()

Flushes the receiver's off-screen buffer to the screen if flushing is enabled and if the last flushWindow message had no effect because flushing was disabled. To avoid unnecessary flushing, use this method rather than flushWindow to flush an NSWindow after flushing has been reenabled.

See Also: flushWindow, disableFlushWindow, enableFlushWindow



frame

public NSRect frame()

Returns the receiver's frame rectangle. The frame rectangle is always reckoned in the screen coordinate system.

See Also: screen, deepestScreen



frameAutosaveName

public String frameAutosaveName()

Returns the name used to automatically save the receiver's frame rectangle data in the defaults system, as set through setFrameAutosaveName. If the receiver has an autosave name, its frame data is written whenever the frame rectangle changes.

See Also: setFrameUsingName



gState

public int gState()

Returns the graphics state object associated with the receiver. 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.

hasDynamicDepthLimit

public boolean hasDynamicDepthLimit()

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.

See Also: setDynamicDepthLimit



hidesOnDeactivate

public boolean hidesOnDeactivate()

Returns true if the receiver is removed from the screen when its application is deactivated, false if it remains on screen.

See Also: setHidesOnDeactivate



initialFirstResponder

public NSView initialFirstResponder()

Returns the NSView that's made first responder the first time the receiver is placed on screen.

See Also: setInitialFirstResponder, setNextKeyView (NSView)



invalidateCursorRectsForView

public void invalidateCursorRectsForView(NSView aView)

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).

See Also: resetCursorRects, resetCursorRects (NSView)



isAutodisplay

public boolean isAutodisplay()

Returns true if the receiver automatically displays its views that are marked as needing it, false if it doesn't. Automatic display typically occurs on each pass through the event loop.

See Also: setAutodisplay, displayIfNeeded, setNeedsDisplay (NSView)



isDocumentEdited

public boolean isDocumentEdited()

Returns true or false according to the argument supplied with the last setDocumentEdited message.

isExcludedFromWindowsMenu

public boolean isExcludedFromWindowsMenu()

Returns true if the receiver's title is omitted from the application's Windows menu, false if it is listed.

See Also: setExcludedFromWindowsMenu



isFlushWindowDisabled

public boolean isFlushWindowDisabled()

Returns true if the receiver's flushing ability has been disabled; otherwise returns false.

See Also: disableFlushWindow, enableFlushWindow



isKeyWindow

public boolean isKeyWindow()

Returns true if the receiver is the key window for the application, false if it isn't.

See Also: isMainWindow, makeKeyWindow



isMainWindow

public boolean isMainWindow()

Returns true if the receiver is the main window for the application, false if it isn't.

See Also: isKeyWindow, makeMainWindow



isMiniaturized

public boolean isMiniaturized()

Returns true if the receiver has been miniaturized, false if it hasn't. A miniaturized window is removed from the screen and replaced by a miniwindow, icon, or button that represents it, called the counterpart.

See Also: miniaturize



isOneShot

public boolean isOneShot()

Returns true if the window device the receiver manages is freed when it's removed from the screen list, false if not. The default is false.

See Also: setOneShot



isReleasedWhenClosed

public boolean isReleasedWhenClosed()

Returns true if the receiver is automatically released after being closed, false if it's simply removed from the screen. The default for NSWindow is true; the default for NSPanel is false.

See Also: setReleasedWhenClosed



isVisible

public boolean isVisible()

Returns true if the receiver is on screen (even if it's obscured by other windows).

See Also: visibleRect (NSView)



isZoomed

public boolean isZoomed()

Description forthcoming.

keyDown

public void keyDown(NSEvent theEvent)

Handles a keyboard event that may need to be interpreted as changing the key view or triggering a mnemonic.

See Also: selectNextKeyView, nextKeyView (NSView), performMnemonic (NSView)



keyViewSelectionDirection

public int keyViewSelectionDirection()

Returns the direction the receiver is currently using to change the key view. This can be one of the values described in "Constants" .

See Also: selectNextKeyView, selectPreviousKeyView



level

public int level()

Returns the level of the receiver as set using setLevel. See "Constants" for a list of possible values.

makeFirstResponder

public boolean makeFirstResponder(NSResponder aResponder)

Attempts to make aResponder the first responder for the receiver. 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 methods 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.

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.

See Also: becomeFirstResponder (NSResponder), resignFirstResponder (NSResponder)



makeKeyAndOrderFront

public void makeKeyAndOrderFront(Object anObject)

Moves the receiver to the front of the screen list, within its level, and makes it the key window.

See Also: orderFront, orderBack, orderOut, orderWindow, setLevel



makeKeyWindow

public void makeKeyWindow()

Makes the receiver the key window.

See Also: makeMainWindow, becomeKeyWindow, isKeyWindow



makeMainWindow

public void makeMainWindow()

Makes the receiver the main window.

See Also: makeKeyWindow, becomeMainWindow, isMainWindow



maxSize

public NSSize maxSize()

Returns the maximum size to which the receiver's frame can be sized either by the user or by the setFrame... methods other than setFrame.

See Also: setMaxSize, minSize, aspectRatio, resizeIncrements



minSize

public NSSize minSize()

Returns the minimum size to which the receiver's frame can be sized either by the user or by the setFrame... methods other than setFrame.

See Also: setMinSize, maxSize, aspectRatio, resizeIncrements



miniaturize

public void miniaturize(Object sender)

Removes the receiver from the screen list and displays its counterpart in the appropriate location.

See Also: deminiaturize



miniwindowImage

public NSImage miniwindowImage()

Returns the image displayed in the receiver's miniwindow.

See Also: setMiniwindowImage, miniwindowTitle



miniwindowTitle

public String miniwindowTitle()

Returns the title displayed in the receiver's miniwindow.

See Also: setMiniwindowTitle, miniwindowImage



mouseLocationOutsideOfEventStream

public NSPoint mouseLocationOutsideOfEventStream()

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.

See Also: currentEvent (NSApplication)



nextEventMatchingMask

public NSEvent nextEventMatchingMask(int mask)

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. See the method description in the NSApplication class specification for more information.

public NSEvent nextEventMatchingMask( int mask, NSDate expirationDate, String mode, boolean dequeue)

Forwards the message to the global NSApplication object, NSApp. See the method description in the NSApplication class specification for more information.

orderBack

public void orderBack(Object sender)

Moves the receiver to the back of its level in the screen list, without changing either the key window or the main window.

See Also: orderFront, orderOut, orderWindow, makeKeyAndOrderFront, level



orderFront

public void orderFront(Object sender)

Moves the receiver to the front of its level in the screen list, without changing either the key window or the main window.

See Also: orderBack, orderOut, orderWindow, makeKeyAndOrderFront, level



orderFrontRegardless

public void orderFrontRegardless()

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. 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.

See Also: orderFront, level



orderOut

public void orderOut(Object sender)

Takes the receiver out of the screen list. 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.

See Also: orderFront, orderBack, orderWindow, setReleasedWhenClosed



orderWindow

public void orderWindow( int place, int otherWindowNumber)

Repositions the receiver's window device in the Window Server's screen list. 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.

See Also: orderFront, orderBack, orderOut, makeKeyAndOrderFront, level, windowNumber



performClose

public void performClose(Object sender)

Simulates the user clicking the close button by momentarily highlighting the button and then closing the window. 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), this method calls the NSBeep function.

See Also: styleMask, performClick (NSButton), performMiniaturize



performDragOperation

public boolean performDragOperation(NSDraggingInfo aDraggingInfo)

Description forthcoming.

performMiniaturize

public void performMiniaturize(Object sender)

Simulates the user clicking the miniaturize button by momentarily highlighting the button then miniaturizing the window. If the receiver doesn't have a miniaturize button or can't be miniaturized for some reason, this method calls the NSBeep function.

See Also: close, styleMask, performClick (NSButton), performClose



performZoom

public void performZoom(Object sender)

Simulates the user clicking the zoom box by momentarily highlighting the button and then zooming the window. If the receiver doesn't have a zoom box or can't be zoomed for some reason, this method calls the NSBeep function.

See Also: styleMask, performClick (NSButton), zoom



postEvent

public void postEvent( NSEvent anEvent, boolean flag)

Forwards the message to the global NSApplication object, NSApp.

prepareForDragOperation

public boolean prepareForDragOperation(NSDraggingInfo aDraggingInfo)

Description forthcoming.

print

public void print(Object sender)

Runs the Print panel, and if the user chooses an option other than canceling, prints the receiver (its frame view and all subviews).

registerForDraggedTypes

public void registerForDraggedTypes(NSArray pboardTypes)

Registers pboardTypes as the pasteboard types the receiver will accept as the destination of an image-dragging session.

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.

See Also: unregisterDraggedTypes



representedFilename

public String representedFilename()

Returns the name of the file the receiver represents.

See Also: setRepresentedFilename



resetCursorRects

public void resetCursorRects()

Invokes discardCursorRects to clear the receiver's cursor rectangles, then sends resetCursorRects to every NSView in the receiver's view hierarchy.

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.



resignKeyWindow

public void resignKeyWindow()

Never invoke this method; it's invoked automatically when the NSWindow resigns key window status. 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.

See Also: becomeKeyWindow, resignMainWindow



resignMainWindow

public void resignMainWindow()

Never invoke this method; it's invoked automatically when the NSWindow resigns main window status. This method sends windowDidResignMain to the receiver's delegate and posts a WindowDidResignMainNotification to the default notification center.

See Also: becomeMainWindow, resignKeyWindow



resizeFlags

public int resizeFlags()

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. 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.

resizeIncrements

public NSSize resizeIncrements()

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. These amounts are whole number values, 1.0 or greater. You can set an NSWindow's size to any value programmatically.

See Also: setResizeIncrements, setAspectRatio, setFrame



restoreCachedImage

public void restoreCachedImage()

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. You must invoke flushWindow after this method to guarantee proper redisplay. An NSWindow automatically discards its cached image rectangles when it displays.

See Also: discardCachedImage, display



saveFrameUsingName

public void saveFrameUsingName(String name)

Saves the receiver's frame rectangle in the user defaults system. 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.

See Also: stringWithSavedFrame



screen

public NSScreen screen()

Returns the screen the receiver is on. If the receiver is partly on one screen and partly on another, the screen where most of it lies is returned.

See Also: deepestScreen



selectKeyViewFollowingView

public void selectKeyViewFollowingView(NSView aView)

Sends the NSView message nextValidKeyView to aView, and if that message returns an NSView, invokes makeFirstResponder with the returned NSView.

See Also: selectKeyViewPrecedingView



selectKeyViewPrecedingView

public void selectKeyViewPrecedingView(NSView aView)

Sends the NSView message previousValidKeyView to aView, and if that message returns an NSView, invokes makeFirstResponder with the returned NSView.

See Also: selectKeyViewFollowingView



selectNextKeyView

public void selectNextKeyView(Object sender)

Searches for a candidate key view and, if it finds one, invokes makeFirstResponder to establish it as the first responder. The candidate is one of the following (searched for in this order):

See Also: selectPreviousKeyView, selectKeyViewFollowingView



selectPreviousKeyView

public void selectPreviousKeyView(Object sender)

Searches for a candidate key view and, if it finds one, invokes makeFirstResponder to establish it as the first responder. The candidate is one of the following (searched for in this order):

See Also: selectNextKeyView, selectKeyViewPrecedingView



sendEvent

public void sendEvent(NSEvent theEvent)

Dispatches mouse and keyboard events sent to the receiver by the NSApplication object. Never invoke this method directly.

setAcceptsMouseMovedEvents

public void setAcceptsMouseMovedEvents(boolean flag)

Sets whether the receiver accepts mouse-moved events and distributes them to its responders. If flag is true it does accept them; if flag is false it doesn't. NSWindows don't accept mouse-moved events by default.

See Also: acceptsMouseMovedEvents



setAspectRatio

public void setAspectRatio(NSSize ratio)

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.

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.

See Also: aspectRatio, setFrame



setAutodisplay

public void setAutodisplay(boolean flag)

Sets whether the receiver automatically displays its views that are marked as needing it. 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.

See Also: isAutodisplay, displayIfNeeded, displayIfNeeded (NSView)



setBackgroundColor

public void setBackgroundColor(NSColor aColor)

Sets the receiver's background color to aColor.

See Also: backgroundColor



setBackingType

public void setBackingType(int backingType)

Sets the receiver's backing store type to backingType. The following are valid backing store types:

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 (a error is generated if you attempt to do so).

See Also: backingType



setContentSize

public void setContentSize(NSSize aSize)

Sets the size of the receiver's content view to aSize, which is expressed in the receiver's base coordinate system. This 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.

See Also: setFrame, contentRectForFrameRect, frameRectForContentRect



setContentView

public void setContentView(NSView aView)

Makes aView the receiver's content view; the previous content view is removed from the receiver's view hierarchy. 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.

See Also: contentView, setContentSize



setDefaultButtonCell

public void setDefaultButtonCell(NSButtonCell aButtonCell)

Makes aButtonCell's key equivalent the Return (or Enter) key, so when the user presses Return that button performs as if clicked. See the method description for defaultButtonCell for more information.

See Also: disableKeyEquivalentForDefaultButtonCell, enableKeyEquivalentForDefaultButtonCell



setDelegate

public void setDelegate(Object anObject)

Makes anObject the receiver's delegate, without retaining it. 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.

See Also: delegate, tryToPerform, sendActionToTargetFromSender (NSApplication)



setDepthLimit

public void setDepthLimit(int limit)

Sets the depth limit of the receiver to limit, which can be determined using the BestDepth function. 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.

See Also: depthLimit, defaultDepthLimit, setDynamicDepthLimit



setDocumentEdited

public void setDocumentEdited(boolean flag)

Sets whether the receiver's document has been edited and not saved. 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.



setDynamicDepthLimit

public void setDynamicDepthLimit(boolean flag)

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. 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.

See Also: hasDynamicDepthLimit, defaultDepthLimit



setExcludedFromWindowsMenu

public void setExcludedFromWindowsMenu(boolean flag)

Sets whether the receiver's title is omitted from the application's Windows menu. If flag is true it's omitted; if flag is false, it's listed when it or its miniwindow is on screen. The default is false.

See Also: isExcludedFromWindowsMenu



setFrame

public void setFrame( NSRect frameRect, boolean flag)

Sets the origin and size of the receiver's frame rectangle according to frameRect, thereby setting its position and size on screen, and invokes display if flag is true. Note that the Window Server limits window position coordinates to ±16,000 and sizes to 10,000.

See Also: frame, setFrameFromString, setFrameOrigin, setFrameTopLeftPoint, setFrameUsingName



setFrameAutosaveName

public boolean setFrameAutosaveName(String name)

Sets the name used to automatically save the receiver's frame rectangle in the defaults system to 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).

See Also: removeFrameUsingName, stringWithSavedFrame, setFrameFromString



setFrameFromString

public void setFrameFromString(String aString)

Sets the receiver's frame rectangle from the string representation aString, a representation previously creating using stringWithSavedFrame. 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.

setFrameOrigin

public void setFrameOrigin(NSPoint aPoint)

Positions the lower-left corner of the receiver's frame rectangle at aPoint in screen coordinates. Note that the Window Server limits window position coordinates to ±16,000.

See Also: setFrame, setFrameTopLeftPoint



setFrameTopLeftPoint

public void setFrameTopLeftPoint(NSPoint aPoint)

Positions the top-left corner of the receiver's frame rectangle at aPoint in screen coordinates. 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.

See Also: cascadeTopLeftFromPoint, setFrame, setFrameOrigin



setFrameUsingName

public boolean setFrameUsingName(String name)

Sets the receiver's frame rectangle by reading the rectangle data stored in name from the defaults system. 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.

See Also: setFrameAutosaveName, removeFrameUsingName, stringWithSavedFrame, setFrameFromString



setHidesOnDeactivate

public void setHidesOnDeactivate(boolean flag)

Sets whether the receiver is removed from the screen when the application is inactive. 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 on screen. The default for NSWindow is false; the default for NSPanel is true.

See Also: hidesOnDeactivate



setInitialFirstResponder

public void setInitialFirstResponder(NSView aView)

Sets aView as the NSView that's made first responder (also called the key view) the first time the receiver is placed on screen.

See Also: initialFirstResponder



setLevel

public void setLevel(int newLevel)

Sets the receiver's window level to newLevel. Some useful predefined values are described in "Constants" .

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

See Also: level, orderWindow, orderFront, orderBack



setMaxSize

public void setMaxSize(NSSize aSize)

Sets the maximum size to which the receiver's frame can be sized to 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.

See Also: maxSize, setMinSize, setAspectRatio, setResizeIncrements



setMinSize

public void setMinSize(NSSize aSize)

Returns the minimum size to which the receiver's frame can be sized to aSize. The minimum size constraint is enforced for resizing by the user as well as for the setFrame... methods other than setFrame.

See Also: minSize, setMaxSize, setAspectRatio, setResizeIncrements



setMiniwindowImage

public void setMiniwindowImage(NSImage anImage)

Sets the image displayed by the receiver's miniwindow to anImage.

See Also: miniwindowImage, isMiniaturized



setMiniwindowTitle

public void setMiniwindowTitle(String aString)

Sets the title of the receiver's miniaturized counterpart to aString and redisplays it. A miniwindow's title normally reflects that of its full-size counterpart, abbreviated to fit if necessary. Although this method allows you to set the miniwindow's title explicitly, changing the full-size NSWindow's title (through setTitle or setTitleWithRepresentedFilename) automatically changes the miniwindow's title as well.

See Also: miniwindowTitle



setOneShot

public void setOneShot(boolean flag)

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). 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.

See Also: isOneShot



setReleasedWhenClosed

public void setReleasedWhenClosed(boolean flag)

Sets whether the receiver is merely hidden (false) or hidden and then released (true) when it receives a close message. The default for NSWindow is true; the default for NSPanel is false.

See Also: close, isReleasedWhenClosed



setRepresentedFilename

public void setRepresentedFilename(String path)

Sets the name of the file the receiver represents to path.

See Also: representedFilename, setTitleWithRepresentedFilename



setResizeIncrements

public void setResizeIncrements(NSSize increments)

Restricts the user's ability to resize the window so the width and height change by multiples of increments.width and increments.height as the user resizes the window. 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.

See Also: resizeIncrements, setFrame



setTitle

public void setTitle(String aString)

Sets the string that appears in the receiver's title bar (if it has one) to aString and displays the title. Also sets the title of the receiver's miniwindow.

See Also: title, setTitleWithRepresentedFilename, setMiniwindowTitle



setTitleWithRepresentedFilename

public void setTitleWithRepresentedFilename(String path)

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. The filename is displayed first, followed by an em dash and the path for the directory containing the file. The em dash is offset by two spaces on either side. For example:

This method also sets the title of the receiver's miniwindow.

See Also: title, setTitle, setMiniwindowTitle



setViewsNeedDisplay

public void setViewsNeedDisplay(boolean flag)

Sets whether the receiver's views need display (true) or do not need display (false). You should rarely need to invoke this method; NSView's setNeedsDisplay and similar methods invoke it automatically.

See Also: viewsNeedDisplay



setWindowController

public void setWindowController(NSWindowController windowController)

Description forthcoming.

stringWithSavedFrame

public String stringWithSavedFrame()

Returns a string that represents the receiver's frame rectangle in a format that can be used with a later setFrameUsingName message.

styleMask

public int styleMask()

Returns the receiver's style mask, indicating what kinds of control items it displays. See the information about the style mask in "Constants" . An NSWindow's style is set when the object is initialized. Once set, it can't be changed.

title

public String title()

Returns the string that appears in the title bar of the receiver.

See Also: setTitle, setTitleWithRepresentedFilename



tryToPerform

public boolean tryToPerform( NSSelector anAction, Object anObject)

Dispatches action messages. 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 using its inherited NSObject method performSelector:withObject:. If either the receiver or its delegate accepts anAction, this method returns true; otherwise it returns false.

unregisterDraggedTypes

public void unregisterDraggedTypes()

Unregisters the receiver as a possible destination for dragging operations.

See Also: registerForDraggedTypes



update

public void update()

Updates the window. 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 on screen. You can manually cause an update message to be sent to all visible NSWindows through NSApplication's updateWindows method.

See Also: setWindowsNeedUpdate (NSApplication), updateWindows (NSApplication)



useOptimizedDrawing

public void useOptimizedDrawing(boolean flag)

Informs the receiver whether to optimize focusing and drawing when displaying its NSViews. 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.

validRequestorForTypes

public Object validRequestorForTypes( String sendType, String returnType)

Searches for an object that responds to a Services request by providing input of sendType and accepting output of 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. See the Services documentation in Programming Topics for more information.

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.

See Also: validRequestorForTypes (NSResponder and NSApplication)



viewsNeedDisplay

public boolean viewsNeedDisplay()

Returns true if any of the receiver's NSView's need to be displayed, false otherwise.

See Also: setViewsNeedDisplay



windowController

public Object windowController()

Description forthcoming.

windowNumber

public int windowNumber()

Returns the window number of the receiver's window device. 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 and in the Application Kit functions WindowList and ConvertWindowNumberToGlobal.

If the receiver doesn't have a window device, the value returned will be equal to or less than 0.

See Also: setOneShot



worksWhenModal

public boolean worksWhenModal()

Returns true if the receiver is able to receive keyboard and mouse events even when some other window is being run modally, false otherwise. NSWindow's implementation of this method returns false. Only subclasses of NSPanel should override this default.

See Also: setWorksWhenModal (NSPanel)



zoom

public void zoom(Object sender)

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). 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:

  1. 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
  2. Adjusts the resulting frame, if necessary, to fit on the current screen.
  3. 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.
  4. 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 does not change.
  5. 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.
  6. If the window currently allows zooming, sets the new frame.



Methods Implemented By the Delegate


windowShouldClose

public abstract boolean windowShouldClose(Object sender)

Invoked when the user attempts to close the window or when the NSWindow receives a performClose message. The delegate can return false to prevent sender from closing.

windowShouldZoom

public abstract boolean windowShouldZoom( NSWindow sender, NSRect newFrame)

Invoked just before sender is zoomed. Zooming will change the frame of sender to newFrame. The delegate can return false to prevent sender from zooming.

See Also: windowWillUseStandardFrame



windowWillResize

public abstract NSSize windowWillResize( NSWindow sender, NSSize proposedFrameSize)

Invoked when sender is being resized (whether by the user or through one of the setFrame... methods other than setFrame). 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.



windowWillReturnFieldEditor

public abstract Object windowWillReturnFieldEditor( NSWindow sender, Object anObject)

Invoked when the field editor of sender is requested by 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.

See Also: fieldEditorForObject



windowWillReturnUndoManager

public abstract NSUndoManager windowWillReturnUndoManager(NSWindow sender)

Description forthcoming.

windowWillUseStandardFrame

public abstract NSRect windowWillUseStandardFrame( NSWindow sender, NSRect defaultFrame)

Invoked by the zoom method while determining a frame the window may be zoomed to. Returns the standard frame (described below) for 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.

See Also: windowShouldZoom, zoom (NSWindow class)



windowDidBecomeKey

public abstract void windowDidBecomeKey(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has become key. aNotification is always WindowDidBecomeKeyNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidBecomeMain

public abstract void windowDidBecomeMain(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has become main. aNotification is always WindowDidBecomeMainNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidChangeScreen

public abstract void windowDidChangeScreen(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has changed screens. aNotification is always WindowDidChangeScreenNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidDeminiaturize

public abstract void windowDidDeminiaturize(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has been deminiaturized. aNotification is always WindowDidDeminiaturizeNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidExpose

public abstract void windowDidExpose(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has been exposed. aNotification is always WindowDidExposeNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidMiniaturize

public abstract void windowDidMiniaturize(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has been miniaturized. aNotification is always WindowDidMiniaturizeNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidMove

public abstract void windowDidMove(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has been moved. aNotification is always WindowDidMoveNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidResignKey

public abstract void windowDidResignKey(NSNotification)

Sent by the default notification center immediately after an NSWindow has resigned its status as key window. aNotification is always WindowDidResignKeyNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidResignMain

public abstract void windowDidResignMain(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has resigned its status as main window. aNotification is always WindowDidResignMainNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidResize

public abstract void windowDidResize(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow has been resized. aNotification is always WindowDidResizeNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowDidUpdate

public abstract void windowDidUpdate(NSNotification aNotification)

Sent by the default notification center immediately after an NSWindow receives an update message. aNotification is always WindowDidUpdateNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowWillClose

public abstract void windowWillClose(NSNotification aNotification)

Sent by the default notification center immediately before an NSWindow closes. aNotification is always WindowWillCloseNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowWillMiniaturize

public abstract void windowWillMiniaturize(NSNotification aNotification)

Sent by the default notification center immediately before an NSWindow is miniaturized. aNotification is always WindowWillMiniaturizeNotification. You can retrieve the NSWindow object in question by sending object to aNotification.

windowWillMove

public abstract void windowWillMove(NSNotification aNotification)

Sent by the default notification center immediately before an NSWindow is moved. aNotification is always WindowWillMoveNotification. You can retrieve the NSWindow object in question by sending object to aNotification.


Notifications


WindowDidBecomeKeyNotification

Posted whenever the NSWindow becomes the key window.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has become key.

WindowDidBecomeMainNotification

Posted whenever the NSWindow becomes the main window.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has become main.

WindowDidChangeScreenNotification

Posted whenever a portion of the NSWindow's frame moves onto or off of a screen.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has changed screens.

WindowDidDeminiaturizeNotification

Posted whenever the NSWindow is deminiaturized.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has been deminiaturized.

WindowDidExposeNotification

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.

This notification contains a notification object and a userInfo dictionary. The notification object is the NSWindow that has been exposed. The userInfo dictionary contains the key ExposedRect and an associated value for the rectangle that has been exposed.

WindowDidMiniaturizeNotification

Posted whenever the NSWindow is miniaturized.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has been miniaturized.

WindowDidMoveNotification

Posted whenever the NSWindow is moved.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has moved.

WindowDidResignKeyNotification

Posted whenever the NSWindow resigns its status as key window.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has resigned its key window status.

WindowDidResignMainNotification

Posted whenever the NSWindow resigns its status as main window.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that has resigned its main window status.

WindowDidResizeNotification

Posted whenever the NSWindow's size changes.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow whose size has changed.

WindowDidUpdateNotification

Posted whenever the NSWindow receives an update message.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that received the update message.

WindowWillCloseNotification

Posted whenever the NSWindow is about to close.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to close.

WindowWillMiniaturizeNotification

Posted whenever the NSWindow is about to be miniaturized.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to be miniaturized.

WindowWillMoveNotification

Posted whenever the NSWindow is about to move.

This notification contains a notification object but no userInfo dictionary. The notification object is the NSWindow that is about to move.



Table of Contents