Re: Custom About Box with background shape
Re: Custom About Box with background shape
- Subject: Re: Custom About Box with background shape
- From: Ken Thomases <email@hidden>
- Date: Tue, 08 Nov 2011 21:00:31 -0600
On Nov 7, 2011, at 2:04 PM, Chris Paveglio wrote:
> I have a custom about box, and it's sort of like Adobe apps, where it's not a traditional window but a graphic/image I made that is a shape like a hexagon with a drop shadow.
> It works fine and I can call it and I disable the window background by setting the window alpha to 0.999.
Where did you learn this voodoo?
> One little tiny issue is that when I invoke the about box, for just a millisecond I sort of see the window bounds and background, and then it goes away. The second time I show the about box the blink of background window is not present.
> Is there some way to not have that flash happen the first time? I'm not doing anything in init or awakeFromNib, only this:
>
> -(IBAction)showAboutWindow:(id)sender
> {
> if(!aboutWindow)
> [NSBundleloadNibNamed:@"AboutWindow"owner:self];
You should typically using an instance of NSWindowController or a subclass to load a NIB containing a window. It would make itself the owner, so, if the NIB makes use of File's Owner, you'd want to set the class of File's Owner to be the window controller class. Using a custom window controller class would also take care of this load-NIB-if-window-outlet-is-nil logic and would give you a cleaner place (the -windowDidLoad method) to do this sort of special configuration work.
Using NSBundle to load the NIB and passing your own object as the owner means you have taken on special responsibilities to do proper memory management of the NIB's top-level objects. Are you doing so?
> [aboutWindowsetBackgroundColor:[NSColorclearColor]];
> [aboutWindowsetAlphaValue:0.9999999]; //will only show transparent backgrounds if set to something less than 1.0
I suspect you want to do [aboutWindow setOpaque:NO] instead of this voodoo. And if the shadow is taking a moment to adjust, then you can try [aboutWindow invalidateShadow], but I don't think that should be necessary.
> [aboutWindowcenter];
> [aboutWindowsetStyleMask:NSBorderlessWindowMask];
Typically, you'd use a custom window class and its init method would either be passed the desired style or would be overridden to ignore the passed-in style replacing it with the desired style before calling super.
> [aboutWindowmakeKeyAndOrderFront:nil];
> }
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden