Re: Customize NSAlert?
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