recognizing NSOKButton on custom sheet
recognizing NSOKButton on custom sheet
- Subject: recognizing NSOKButton on custom sheet
- From: Andrew Wilson <email@hidden>
- Date: Fri, 4 Feb 2005 18:54:39 -0500
I'm using a custom sheet, as described in Apple's docs. It's working, except I can't get the sheetDidEnd method to recognize the buttons on the sheet as NSOKButton and NSCancelButton. I even tried specifically setting the tag of my OK button before starting the sheet, as follows
// these 2 statements are in the method where I want to start the sheet
[newPageOKButton setTag:NSOKButton];
[NSApp beginSheet:newPageSheet modalForWindow:mainWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil];
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode == NSOKButton) {
// do something (but the if never goes through)
}
[sheet orderOut:self];
}
The buttons call the following action to end the sheet, so I could test the buttons and put my logic there.
- (id)sender
{
[NSApp endSheet:newPageSheet];
if (sender == newPageOKButton) {
NSLog(@"OK button");
}
}
Would it be proper Cocoa style to also order out the sheet in the action method and just omit the sheetDidEnd method? (The tutorial on sheets at CocoaDevCentral does it that way) still like to know how to correctly set it up using NSOKButton, though.
Thanks,
Andrew Wilson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden