One Quickie


Doing Sheets (NSWindow->General)
To show a sheet in a window, use NSApplication to kick it off:
    [NSApp beginSheet: saveSheet
           modalForWindow: window
           modalDelegate: self
           didEndSelector: @selector(saveSheetDidEnd:returnCode:contextInfo:)
           contextInfo: NULL];
In the controls in the sheet, use something like
    [NSApp endSheet: saveSheet  returnCode: NSOKButton];
To invoke the didEndSelector. Inside of that method, you can check the return code and decide what to do:
- (void) saveSheetDidEnd: (NSWindow *) sheet
              returnCode: (int) returnCode
             contextInfo: (void *) contextInfo
{
    if (returnCode == NSOKButton) {
        // ...
    } else if (returnCode == NSCancelButton) {
        // ...
    } else {
        // ...
    }

    [sheet close];

} // saveSheetDidEnd



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com