Re: Confused in sheets
Re: Confused in sheets
- Subject: Re: Confused in sheets
- From: Jeremy Dronfield <email@hidden>
- Date: Sun, 21 Jul 2002 13:45:55 +0100
On Saturday, July 20, 2002, at 07:54 pm, Aidas wrote:
Today I wanted to attacth sheet to window, but I completely confused
when I
looked at those methods. Could please someone give me example on how to
attach sheet to window and detach it.
It isn't clear exactly what you want to do, but here is an example from
one of my own applications including two alert sheets. I don't know how
relevant it is to what you want. It comes from the window in which the
user enters a licence code.
- (IBAction)enterAction:(id)sender
{
if ([licenceCode isEqualToString:[codeField stringValue]]) {
NSBeginAlertSheet(@"Licence validated", @"Continue", nil, nil,
[self window], self, @selector(validatedSheetDidEnd), nil, nil, @"Thank
you for licensing this copy.\nAll features are now enabled.", nil);
[prefs setObject:[codeField stringValue] forKey:@"Licence"];
} else {
NSBeginAlertSheet(@"Invalid Entry", @"Try Again", nil, nil,
[self window], self, nil, nil, nil, @"%@ is not a valid licence
code.", [codeField stringValue]);
}
}
- (void)validatedSheetDidEnd
{
[NSApp stopModal];
[sRControls setIsLicensed:YES];
[[self window] close];
}
The first sheet has only one button, and calls the -validatedSheetDidEnd
method. The second sheet simply ends and returns the user to the
window. The vital argument in both is the fifth, which specifies the
window the sheet is attached to - here [self window], since this is an
NSWindowController subclass.
- Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.