isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
- Subject: isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
- From: desktoast music productions <email@hidden>
- Date: Mon, 24 Apr 2006 21:06:04 +0200
Hello again.
Accomplishing the task of implementing a nice splash screen while my app
loads its database has confronted me with yet another difficulty.
I¹d like to provide you with some of the code I¹m using maybe there¹s
something I am overlooking?
This is what the source file of my splash screen object looks like:
#import "WDVSplashWindow.h"
@implementation WDVSplashWindow
- (id)initWithContent:(NSView *)splashView {
NSRect splashFrame = [splashView frame];
self = [super initWithContentRect:splashFrame
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered defer:NO];
[self setContentView:splashView];
[self setReleasedWhenClosed:YES];
[self setLevel: NSStatusWindowLevel];
[self setBackgroundColor: [NSColor clearColor]];
[self setAlphaValue:1.0];
[self setOpaque:NO];
[self setHasShadow: YES];
[self center];
return self;
}
- (void)dealloc {
[super dealloc];
}
- (BOOL)canBecomeMainWindow {
return YES;
}
- (BOOL)canBecomeKeyWindow {
return YES;
}
- (BOOL)isMovableByWindowBackground {
return YES;
}
@end
I use it in the awakeFromNib of my NSWindowController subclass like this:
- (void)awakeFromNib {
WDVSplashWindow *splash = [[WDVSplashWindow alloc] initWithContent:[self
splashView]]; //uses the custom view I created in IB
[splash orderFront:nil];
[splash performSelector:@selector(close) withObject:self
afterDelay:3.5];
// all the setup and loading goes here....
And a second time I use it in a method with the ³About...² menu: (instead of
- orderFrontStandardAboutPanel):
- (IBAction)customAboutBoxAction:(id)sender {
WDVSplashWindow *customAboutBox = [[WDVSplashWindow alloc]
initWithContent:[self splashView]];
[customAboutBox orderFront:sender];
}
When launching my app the splash screen is immediately presented. It stays
on screen for 3.5 seconds and disappears right when the main window
displays. So far, so good. But as you can see, I try to override -
(BOOL)isMovableByWindowBackground to make my splash thing moveable. ([splash
setIsMovableByWindowBackground:YES]; didn¹t work).
Now this is what happens: when launching the app, you can grab the splash
screen and move it around. But if you open it via the ³About²-menu while
working wth the program, you can¹t move it.
I performed another test just to check, if this has something to do with
my main window being on screen at the same time in the second case: I put
the delay time in the awakeFromNib to 10 seconds, so the splash screen
continues being visible after the main window is displayed.
This is what happened: If you grab the splash BEFORE the main window
appears, it can be moved until it finally disappears (although the main
window is already visible). BUT if you wait until the main window shows up
and then try to drag the splash it is no longer movable. (there is no
difference if I use makeKeyAndOrderFront: instead of oderFront: - and my
main window is inactive)
I think, there is something fundamental that I don¹t understand here.
Any suggestions?
Yours thankful,
Peter
--
peter schwaiger
desktoast music productions
http://www.autlawmusic.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden