I just rewired my app to try it your way, and can confirm that, when using [window animationForKey:@"frame"] to get the CAAnimation, it doesn't call the delegates for me either. But animationForKey also doesn't return nil, so my first theory is out.

Weird.

But yes, creating a new CAAnimation and then adding it to the window instead of relying on the animation that the window returns seems to solve the problem.

-Pete

On May 25, 2008, at 12:11 AM, Peter Burtis wrote:
I'm no core animation expert, but.

This...
        
        // self is an NSWindow instance
        CAAnimation *anim = [CABasicAnimation animation];
        [anim setDelegate:self];
[self setAnimations:[NSDictionary dictionaryWithObject:anim forKey:@"frame"]];
        [[self animator] setFrame:NSMakeRect(0,0,0,0) display:YES];

... works perfectly in my app, calling the delegate methods and all. All other things being equal, the only difference I see is that you use [window animationForKey:@"frame"] whereas I create a new animation and then add it to the window with [window setAnimations:...].

My *guess* would be that maybe windows don't instantiate default animations until they're needed, whereas frames instantiate them at init. So when you call [window animationForKey:@"frame"] you're getting nil back. But that's just a guess. I really don't know enough about it.

Bug? Feature?  I don't know.  But this could be a workaround, anyway.

-Pete

On May 24, 2008, at 7:11 AM, Milen Dzhumerov wrote:

Hi all,

I've been playing with CA and I tried to set up one my objects as the delegate for the frame change animation for an NSWindow by using the following code:

CABasicAnimation* anim = [window animationForKey:@"frame"];
anim.delegate = self;
[[window animator] setFrame:NSMakeRect(400, 500, 500, 500) display:YES];

Using this, the window correctly animates but the delegate methods (namely animationDidStop:finished: and animationDidStart:) for the CAAnimation do not get called. When I use the exact same piece of code for setting the delegate of view animations, the delegates do get called.

Thanks,
M


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to