On Jun 1, 2008, at 12:19 PM, John Love wrote:

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

You have several issues here:

First, you can't cast the NSAlert to an NSWindow. The endCalculateSheet:code:info: method must have the same types as the prototype.

Second, the returnCodes for the buttons will be NSAlertFirstButtonReturn, NSAlertSecondButtonReturn and NSAlertThirdButtonReturn. The ones you used are only valid if you call alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat :.

Third, you don't need to close or orderOut the NSAlert because it will automatically close when your endCalculateSheet:code:info: method finishes.

See below:

- (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:@"Do you wish to continue calculating?"]; [calculateSheet setInformativeText:@"You have not finished calculating your Spreadsheet."];
        [calculateSheet setAlertStyle:NSWarningAlertStyle];
        
        [calculateSheet beginSheetModalForWindow:docWindow
                                                           modalDelegate:self
                                                          
didEndSelector:@selector(endCalculateSheet:code:info:)
                                                                 
contextInfo:docWindow];
}

- (void) endCalculateSheet:(NSAlert*)theSheet code:(int)returnCode info:(void*)contextInfo
{
        if (returnCode == NSAlertFirstButtonReturn)          // "Continue"
        {
                NSLog(@"Continue button clicked");
        }
else if (returnCode == NSAlertSecondButtonReturn) // "Stop and save"
        {
                NSLog(@"Stop and save button clicked");
        }
else if (returnCode == NSAlertThirdButtonReturn) // "Stop and don't save"
        {
                NSLog(@"Stop and don't save button clicked");
        }
}

--Nathan

_______________________________________________

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