On Apr 26, 2009, at 2:29 PM, Rowan Nairn wrote:

Thanks for the pointers.  I actually figured out a way to do it.  If
you [NSView setWantsLayer:NO] and render the layer yourself like
so.....

- (void)drawRect:(NSRect)dirty {
        CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort];
        CGContextClipToRect(ctx, NSRectToCGRect(dirty));
        [[self layer] renderInContext:ctx];
}

...then the transparent pixels end up being transparent to clicks too!
Can't say I understand what's going on here exactly and I'm guess I'm
using twice as much graphics memory as I need to now but it works.

When you turn on Core Animation, an OpenGL context is created to host the layer tree. The window server treats all OpenGL contexts as opaque to events, so if the window receives events, then the area occupied by the layer tree will always be considered a hit for events, regardless of actual graphical transparency.

While the method you've found should work for most cases (- renderToContext: does not support the full Core Animation drawing model) if your resorting to this, you will likely see better performance doing the drawing work using more traditional methods.
--
David Duncan
Apple DTS Animation and Printing

_______________________________________________

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