Re: isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
Re: isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
- Subject: Re: isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
- From: Matt Neuburg <email@hidden>
- Date: Tue, 25 Apr 2006 09:19:27 -0700
- Thread-topic: isMovableByWindowBackground is not always movable (was:How do I implement a splash screen)
On Mon, 24 Apr 2006 21:06:04 +0200, desktoast music productions
<email@hidden> said:
>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?
Thanks to your excellent description and the included code, I was able to
reproduce what I think is the skeleton of your app, in a few moments. I ran
it, and I could not reproduce the problem: the splash window is draggable
when summoned by menu with the main window already present. (Let me know
offlist if you need me to send you my version of the project.) So perhaps
something else is going on that you have not told us about.
However, I notice that your splash window is completely transparent. So what
is the user supposed to drag it *by*? You don't say anything about what is
in the view, so this could be the problem. It can't be the background, since
the background is clear and transparent; mouse clicks will pass right
through. It can't be text, since that is hard to grab. It can't be a button,
since if the button is disabled it can't be grabbed, and if it is enabled,
the mouse will click it rather than dragging it. So my suggestion is: Try
setOpaque:YES instead of NO, and see if you can drag the window now.
m.
PS. (1) I strongly doubt you want the splash window to be able to become
main. (2) What are you doing about letting the user close the splash window
manually?
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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