1) I found the culprit on the sheet appearing as a separate window, and not
a sheet .. you were right cause somehow the passed docWindow was apparently
nil .. anyway, called my sheet routine from a different part of MyDocument.m
.. and now the sheet appears as a sheet.

2) the problem remaining centers on accessing the various buttons on the
alert sheet

===========
Here is the log result:

[Session started at 2008-06-01 14:05:16 -0400.]
2008-06-01 14:05:18.088 Calculate Medical[2267:10b] NSWindow does not
support utility styleMask 0x10
2008-06-01 14:05:18.097 Calculate Medical[2267:10b] NSWindow does not
support utility styleMask 0x10
2008-06-01 14:05:22.738 Calculate Medical[2267:10b] *** -[NSAlert close]:
unrecognized selector sent to instance 0x1b5520
2008-06-01 14:05:22.769 Calculate Medical[2267:10b] *** -[NSAlert close]:
unrecognized selector sent to instance 0x1b5520

The Debugger has exited with status 0.
===========
Do not understand that utility styleMask stuff .. and .. the NSAlert is
type-cast as a NSWindow when passed to my dlgEndSelector, so that
"unrecognized selector" is mystifying.

Anyway, onto the code ..

I call this method from MyDocument.m and pass the *documentWindow IBOutlet
from MyDocument.h

- (void) showCalculateSheet:(NSWindow*)docWindow {
    NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease];

    [calculateSheet addButtonWithTitle:@"Continue"];
    [calculateSheet addButtonWithTitle:@"Stop and save"];
    [calculateSheet addButtonWithTitle:@"Stop and don't save"];
    [calculateSheet setMessageText:@"You have not finished calculating your
Spreadsheet.\n"
                                    "Do you wish to continue calculating?"];
    [calculateSheet setAlertStyle:NSWarningAlertStyle];

    [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:self
                      didEndSelector:@selector(endCalculateSheet:code:info:)
                      contextInfo:docWindow];
}


- (void) endCalculateSheet:(NSWindow*)theSheet code:(int)returnCode
info:(void*)contextInfo {
    if (returnCode == NSAlertDefaultReturn)          // "Continue"
    {
        NSLog(@"Default Calculate Button clicked");
      }
    else if (returnCode == NSAlertOtherReturn)       // "Stop and save"
    {
        NSLog(@"Other Calculate Button clicked");
    }
    else if (returnCode == NSAlertAlternateReturn)   // "Stop and don't
save"
    {
        NSLog(@"Third Calculate Button clicked");
    }

    [theSheet close];   // have also tried ... [theSheet orderOut:self];
}

Someone a long time ago warned that the learning curve slope for XCODE is
rather steep .. it's not like I wasn't told.

Anyway, thanks bunches as usual

John Love
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to