SplashScreen and RunLoop
SplashScreen and RunLoop
- Subject: SplashScreen and RunLoop
- From: Lorenzo <email@hidden>
- Date: Tue, 15 Jul 2003 21:39:38 +0200
Hi,
I am trying to make my splashScreen appear before an eventual Finder call to
- (BOOL)application:(NSApplication *)theApplication
openFile:(NSString *)filename
So I decided to put the call openSplashScreen: within the method
- (void)applicationWillFinishLaunching:(NSNotification *)notification
It worked fine. Then I added a fine touch: a timer. So even if the user
doesn't press a key to close the splashScreen window, my application fires
the timer which closes the splashScreen window anyway after 3 seconds.
So I wrote the following 3 methods:
////////////////////////////////////////////////
-(void)openSplashScreen
{
if(splashWinCntrl == nil){
splashWinCntrl = [[[SplashWinCntrl alloc]
initWithWindowNibName:@"splash"] retain];
}
if(splashWinCntrl){
timerSplash = [[NSTimer scheduledTimerWithTimeInterval:3
target:self selector:@selector(stopModalWindow)
userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:timerSplash
forMode:NSModalPanelRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:timerSplash
forMode:NSEventTrackingRunLoopMode];
[NSApp runModalForWindow:[splashWinCntrl window]];
[self closeSplashScreen];
}
}
////////////////////////////////////////////////
- (void)stopModalWindow
{
NSLog(@">>>>>>> stopModalWindow");
[NSApp stopModal];
}
////////////////////////////////////////////////
-(void)closeSplashScreen
{
if(timerSplash){
[timerSplash invalidate];
[timerSplash release];
timerSplash = nil;
}
if(splashWinCntrl){
[[splashWinCntrl window] close];
[splashWinCntrl release];
splashWinCntrl = nil;
}
}
Now, the timer fires, but it doesn't close the splashScreen window. I can
see the log string @">>>>>>> stopModalWindow" but the splashScreen remains
there until I click on the window. Why? Is the problem related to the
NSRunLoop before the application did finish? More, if I put a NSButton on
the splashScreen connected to the stopModalWindow: method, if I press that
button, the window closes properly.
So, why the timer doesn't run properly?
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
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.