rendered paste body/* alertHandle */
#import <Cocoa/Cocoa.h>
@interface alertHandle : NSObject
{
IBOutlet NSPanel *window;
NSTimer *timer;
}
- (IBAction)close:(id)sender;
@end
--
#import "alertHandle.h"
@implementation alertHandle
- (IBAction)close:(id)sender
{
timer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(fade:) userInfo:nil repeats:YES];
}
- (void)fade:(NSTimer *)theTimer
{
if ([window alphaValue] > 0.0) {
// If window is still partially opaque, reduce its opacity.
[window setAlphaValue:[window alphaValue] - 0.1];
} else {
// Otherwise, if window is completely transparent, destroy the timer and close the window.
[timer invalidate];
// [timer release];
timer = nil;
[window close];
// Make the window fully opaque again for next time.
[window setAlphaValue:1.0];
}
}
@end