Splash panels, was "Centering a window"
Splash panels, was "Centering a window"
- Subject: Splash panels, was "Centering a window"
- From: "T.G. McLean" <email@hidden>
- Date: Fri, 22 Aug 2003 15:59:26 -0600
>
I am trying to center my applications splash screen. I believe I need to
use
>
the center method. What I am not sure of is _when_ to use the center method.
I
>
currently have it in the windowDidLoad method, but, it does not seem to
have
>
an affect, the window is displayed at my default position.
>
>
What is the best method of centering a splash screen?
>
>
Tom Gray
Hey, Tom --
I9ve got a splash panel working in a document-based, heuristic app. (ie.,
splash panel fires, followed by the document in some way, shape, or form,
eg., new doc., most recent docs, etc.):
------------------
In 3AppController.h2:
extern NSTimeInterval _SplashPause;
------------------
In 3AppController.m2:
// Pause (seconds) in the splash screen startup.
NSTimeInterval _SplashPause = 1.5;
....
- (void) applicationWillFinishLaunching: (NSNotification*)note;
{
// Show splash panel, then hide it.
[self showSplashPanel];
}
....
- (void) showSplashPanel
{
BOOL successful;
NSTimer* pause;
// Call splash panel.
if (!splashPanel) {
successful = [NSBundle loadNibNamed: @"Splash" owner: self];
if (!successful) {
NSLog(@"Couldn't load nib 'Splash'.");
} else { NSLog(@"Loading splash panel."); }
}
[splashPanel center];
[splashPanel setLevel: NSFloatingWindowLevel];
[splashPanel makeKeyAndOrderFront: nil];
// Register a timer for the splash panel's closing; fire it after time
allotted passes.
pause = [NSTimer scheduledTimerWithTimeInterval: _SplashPause
target: self
selector: @selector(hideSplashPanel)
userInfo: nil
repeats: NO];
}
....
- (void) hideSplashPanel
{
NSLog(@"Hiding splash panel.");
[splashPanel orderOut: nil];
}
------------------
In 3MyDoc2:
- (void) awakeFromNib
{
// Layout window position on screen.
NSLog(@"Laying out window on screen.");
[window center];
[window setLevel: NSNormalWindowLevel];
[window makeKeyAndOrderFront: nil];
...
}
------------------
Works fine.
The only problem I have with it is that the 3[window center]2 call in
3MyDoc2 doesn9t work -- the doc window goes somewhere else (say, where
you9ve placed it in IB).
I think it9s tied up in NSTimer9s placement in the event queue, and the
sequence through which the splash panel and doc windows are resigning and
being made key. Still working on it.
HTH,
-- TG
_______________________________________________
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.