Re: Which CA Layer am I dragging over?
Re: Which CA Layer am I dragging over?
- Subject: Re: Which CA Layer am I dragging over?
- From: David Duncan <email@hidden>
- Date: Thu, 28 Jan 2010 09:38:17 -0800
On Jan 28, 2010, at 9:26 AM, K. Darcy Otto wrote:
> The problem is that I'm having difficulty setting up the NSTrackingAreas. Given CA layer x, I want to discover the position of x in the window so I can set up the tracking area. Is this the right way to solve this problem? If so, how do I get the rect for layer x?
NSRectFromCGRect() is basically just a typecast, but you need a coordinate conversion. The way to do this is to first convert the bounds of layer X to a rectangle in the coordinate system of your view's layer, which can be done with -convertRect:fromLayer: (note, you want bounds NOT frame here – if you use frame you need to convert from layer x's superlayer because the frame is in the layer' superlayer's coordinate system).
Overall you may find it easier to simply setup a tracking area for the entire view and then hit test to find the layer of interest instead, especially since moving the layers around would mean moving the tracking areas around too.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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