Skip navigation.
 
mlRe: Alert Sheets hard wired in Interface Builder
FROM : John Love
DATE : Sun Jun 01 20:19:06 2008

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

Related mailsAuthorDate
mlAlert Sheets hard wired in Interface Builder John Love May 27, 22:28
mlRe: Alert Sheets hard wired in Interface Builder Sherman Pendley May 27, 22:38
mlRe: Alert Sheets hard wired in Interface Builder Kyle Sluder May 27, 22:40
mlRe: Alert Sheets hard wired in Interface Builder Jens Alfke May 28, 06:06
mlRe: Alert Sheets hard wired in Interface Builder Graham Cox May 28, 06:24
mlRe: Alert Sheets hard wired in Interface Builder Scott Ribe May 29, 05:29
mlRe: Alert Sheets hard wired in Interface Builder Kyle Sluder May 29, 05:38
mlRe: Alert Sheets hard wired in Interface Builder Jens Alfke May 29, 05:39
mlRe: Alert Sheets hard wired in Interface Builder Graham Cox May 29, 05:58
mlRe: Alert Sheets hard wired in Interface Builder Chris Hanson May 29, 07:44
mlRe: Alert Sheets hard wired in Interface Builder John Love May 31, 17:43
mlRe: Alert Sheets hard wired in Interface Builder John Love May 31, 18:40
mlRe: Alert Sheets hard wired in Interface Builder Keary Suska May 31, 19:08
mlRe: Alert Sheets hard wired in Interface Builder Jens Alfke May 31, 19:22
mlRe: Alert Sheets hard wired in Interface Builder John Love Jun 1, 20:19
mlRe: Alert Sheets hard wired in Interface Builder Jens Alfke Jun 1, 21:07
mlRe: Alert Sheets hard wired in Interface Builder Nathan Kinsinger Jun 1, 21:15
mlRe: Alert Sheets hard wired in Interface Builder John Love Jun 3, 22:27