• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSWindow CoreAnimation Delegate not being called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindow CoreAnimation Delegate not being called


  • Subject: Re: NSWindow CoreAnimation Delegate not being called
  • From: Peter Burtis <email@hidden>
  • Date: Sun, 25 May 2008 00:28:53 -0400

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 (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


References: 
 >NSWindow CoreAnimation Delegate not being called (From: Milen Dzhumerov <email@hidden>)
 >Re: NSWindow CoreAnimation Delegate not being called (From: Peter Burtis <email@hidden>)

  • Prev by Date: Re: NSWindow CoreAnimation Delegate not being called
  • Next by Date: to launch safari with an URL
  • Previous by thread: Re: NSWindow CoreAnimation Delegate not being called
  • Next by thread: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
  • Index(es):
    • Date
    • Thread