Core Animation NSTrackingArea
Core Animation NSTrackingArea
- Subject: Core Animation NSTrackingArea
- From: Yvan BARTHÉLEMY <email@hidden>
- Date: Tue, 16 Dec 2008 16:21:05 +0100
Hi,
For my project, I want to add mouse support in Core Animation views.
For this, when I create a Core Animation button, I associate to the
view a NSTrackingArea with the frame of my button. This way I can get
mouse Up, Down, Entered and Exited events and implement the behavior
of my button and visual feedback. Until here, this works perfectly.
The problem is that I need to remove the tracking rects when the
button disappear from the view. That is that event that is painful to
detect.
For now, I have a working solution, but it looks like dirty code and
I'm not sure if this is really safe. I remove the tracking rect when
the bound are updated by subclassing [CALayer setNeedsLayout], which
is fine, when the view is removed by subclassing [CALayer
removeFromSublayer] (which is not fine because it's not called when
you directly remove the superlayer), in the dealloc method (this one
causes me a problem, as, this is not just memory management and I have
no guarantee dealloc is called), and the worst one : I registered for
the notification applicationWillTerminate (I need this, because if
dealloc is called after the windows's contentView has been
deallocated, this simply crashes as contentView is not nil).
What do you think I should do with this ?
Best Regards,
Yvan BARTHÉLEMY_______________________________________________
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