• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Alert Sheets hard wired in Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alert Sheets hard wired in Interface Builder


  • Subject: Re: Alert Sheets hard wired in Interface Builder
  • From: Nathan Kinsinger <email@hidden>
  • Date: Sun, 1 Jun 2008 13:15:34 -0600


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 (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Alert Sheets hard wired in Interface Builder
      • From: "John Love" <email@hidden>
References: 
 >Re: Alert Sheets hard wired in Interface Builder (From: "John Love" <email@hidden>)

  • Prev by Date: Re: Alert Sheets hard wired in Interface Builder
  • Next by Date: Re: Predicate expressions
  • Previous by thread: Re: Alert Sheets hard wired in Interface Builder
  • Next by thread: Re: Alert Sheets hard wired in Interface Builder
  • Index(es):
    • Date
    • Thread