i'm attempting to fade my windows on quit, but the following code only seems to work if i have a custom quit method like -(IBAction)quitAppid)sender. i'm trying to override the applictionWillTerminate so the quit from the dock menu will also fade out windows, instead of abruptly quit. i know this new applicationWillTerminate method is getting called correctly because NSLog is outputting text before the app quits, but the fade out isn't being called. is it because this function is relying on a secondary funtion to complete it's task? how can i write it all in one function? any thoughts?
Code:
- (void)applicationWillTerminate:(NSNotification *)notification
{
NSLog (@"Application Terminate Override");
SetSystemUIMode(kUIModeNormal, 0);
timer = [[NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(allWindowsFadeOUT:) userInfo:nil repeats:YES] retain];
}
- (void)allWindowsFadeOUT:(NSTimer *)theTimer
{
if (([mainWindow alphaValue] > 0.0) || ([secondWindow alphaValue] > 0.0)){
[mainWindow setAlphaValue:[mainWindow alphaValue] - 0.1];
[secondWindow setAlphaValue:[secondWindow alphaValue] - 0.1];
}
else
{
[timer invalidate];
[timer release];
timer = nil;
[NSApp terminate:nil];
}
}