< Previous PageNext Page > Hide TOC

How a Window is Displayed

Display of an NSWindow object begins with the drawing performed by its view objects, which accumulates in the window’s display buffer or appears immediately on the screen. Windows, like NSView objects, can be displayed unconditionally or merely marked as needing display, using the display and setViewsNeedDisplay: methods, respectively. A displayIfNeeded message causes the window’s views to display only if they’ve been marked as needing display. Normally, any time a view is marked as needing display, the window 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 a window, 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 window. 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, a window can print itself in its entirety, just as a view can. The print: method runs the application’s Print panel and causes the window’s frame view to print itself. dataWithEPSInsideRect: behaves similarly. For additional information see Printing Programming Topics for Cocoa.



< Previous PageNext Page > Hide TOC


© 2002, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.