4.3. Building Windows

Applications use windows in many different ways. Document windows, like those used by word processors or image viewers, tend to be large, resizable windows that contain only a few user interface elements. Utility windows and inspectors tend to have a lot of controls packed into a small area. Dialog and sheets are often the simplest windows, containing only enough items to ask a simple question and collect an answer from the user.

Interface Builder's drag-and-drop interface should be well suited for building windows. Theoretically, all you need to do is drag some controls into your window and you're good to go. In practice, you also need to make sure the controls are arranged properly in the window, accounting both for your application's needs and the spacing rules set forth in the Apple Human Interface Guidelines. Fortunately for you, Interface Builder includes some useful tricks that make this easy.

In the following Try It Out, you build a window to be used as a modal dialog box or a sheet. A modal window locks out portions of your application's interface until you close that window. Modal dialog boxes block the entire application, whereas sheets block access only to the window in which they're anchored. The window contains a number of controls arranged in a specific layout. The window also includes OK and Cancel buttons that allow the user to dismiss the window. As is often the case with small dialog boxes and sheets, this window will not be resizable. ...

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.