• 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: Customize NSAlert?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Customize NSAlert?


  • Subject: Re: Customize NSAlert?
  • From: Nick Zitzmann <email@hidden>
  • Date: Mon, 5 Feb 2007 13:37:18 -0700


On Feb 4, 2007, at 8:58 AM, Jerry Krinock wrote:

Am I doing something wrong, or do I have to use the yucky old
NSGetInformationalAlertPanel and customize it instead?

Something like this works for me: (warning - typed in Mail, untested, use at your own risk, etc.)


NSAlert *alert = [[NSAlert alloc] init];
NSButton *dontShowAgainButton;

[alert setMessageText:@"Title of alert"];
[alert setInformativeText:@"Body of alert"];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Don't show this warning again"];

dontShowAgainButton = [[alert buttons] objectAtIndex:1];
[dontShowAgainButton setButtonType:NSSwitchButton];
[dontShowAgainButton setTarget:nil];
[dontShowAgainButton setAction:nil];

[alert runModal];
if ([dontShowAgainButton state] == NSOnState)
{
	// the user checked the box, so do something about it here
}
[alert release];

Nick Zitzmann
<http://www.chronosnet.com/>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Customize NSAlert? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Releasing WebView
  • Next by Date: Text Containers in NSView
  • Previous by thread: Re: Customize NSAlert?
  • Next by thread: Re: Customize NSAlert?
  • Index(es):
    • Date
    • Thread