views:

171

answers:

1

Hi,

I have a custom window (matt gemells Transparent Window class) and I need to change the window's alpha value to achieve a fade in/out effect and perform a "makeKeyAndOrderFront:".

However this does not work.

What I did:

I imported the header:

#import "TransparentWindow.h"

Then tried:

[TransparentWindow setAlphaValue:0.5];

[TransparentWindow makeKeyAndOrderFront:self];

This gave me a warning that "Transparent Window" may not respond to either of the code above. So I attempted to implement the "setAlphaValue" into Transparent Window by adding:

- (void)setAlphaValue:(CGFloat)windowAlpha
{
    [super setAlphaValue:windowAlpha];   
}

but the 2 warnings won't go away. How can I fix this?

+1  A: 
[TransparentWindow setAlphaValue:0.5];
[TransparentWindow makeKeyAndOrderFront:self];

This gave me a warning that "Transparent Window" may not respond to either of the code above.

That's because it (the TransparentWindow class) doesn't.

You need to send those messages to a TransparentWindow instance, not to the TransparentWindow class.

So I attempted to implement the "setAlphaValue" into Transparent Window by adding:

- (void)setAlphaValue:(CGFloat)windowAlpha
{
    [super setAlphaValue:windowAlpha];   
}

If this NSWindow method had not existed, calling it from a method in a subclass would not solve that problem.

Peter Hosey