XxtraLarGe
2004.01.19, 07:43 AM
I'm trying to make a sheet drop down after a sound is played.
NSSound has the delegate method -(void)sound:(NSSound *)aSound didFinishPlaying:(BOOL)aBool. I figured that I could use that to trigger a sheet. Here's the code that I wrote:
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)aBool {
NSString *msg = @"You have won the game!";
SEL sel = @selector(sheetClosed:returnCode:contextInfo:);
if (aBool) {
NSBeginAlertSheet(@"Game Over!",
@"Play Again",
@"Close",
nil,
[self window],
self,
sel,
NULL,
[self window],
msg,
nil);
}
}
- (void)sheetClosed:(NSWindow *)sheet
returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
if (returnCode == NSAlertDefaultReturn) {
[self reset];
}
}
I have this code at the bottom of my Custom View class, and not in a separate Delegate class. It compiles without error, but doesn't do anything. Any ideas?
NSSound has the delegate method -(void)sound:(NSSound *)aSound didFinishPlaying:(BOOL)aBool. I figured that I could use that to trigger a sheet. Here's the code that I wrote:
- (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)aBool {
NSString *msg = @"You have won the game!";
SEL sel = @selector(sheetClosed:returnCode:contextInfo:);
if (aBool) {
NSBeginAlertSheet(@"Game Over!",
@"Play Again",
@"Close",
nil,
[self window],
self,
sel,
NULL,
[self window],
msg,
nil);
}
}
- (void)sheetClosed:(NSWindow *)sheet
returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
if (returnCode == NSAlertDefaultReturn) {
[self reset];
}
}
I have this code at the bottom of my Custom View class, and not in a separate Delegate class. It compiles without error, but doesn't do anything. Any ideas?