I'm having some difficulties translating between a Core Animation layer size, and the size of that layer in the NSView subclass I'm using. I can identify the layer from a mouseclick without difficulty, using the following code:

-(void)mouseDown:(NSEvent *)theEvent
{
NSPoint translated = [window convertScreenToBase:[NSEvent mouseLoctaion];
        CGPoint point = NSPointToCGPoint(translated);

CALayer *rootLayer = [[window contentView] layer]; // give me the background layer of the window id hitLayer = [rootLayer hitTest:point]; // gives me the CALayer that was clicked

        ...
}

But now, I want to see what the size of the hitLayer is, in the window's coordinate system. The following doesn't work:

NSRect rect = NSRectFromCGRect([hitLayer frame]);
float width = rect.size.width;

That is, it returns a width, but not the width in the current window coordinates. Any ideas? Thanks.
_______________________________________________

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 arch...@mail-archive.com

Reply via email to