On Feb 16, 2009, at 12:45 PM, David Duncan wrote:
The simplest solution, if you can mange it, is to set the view's layer to your own layer, at which point AppKit will take a hands off approach and allow you to determine when the layer should go away.

We are also mixing hosting & backing a bit, but only barely. The problem we've run into with setting our own layer on the view is that then all the super-seekrit compositing & resizing NSView does for its layers doesn't happen. In particular, since we want our own layers _and_ we want a field editor _and_ we want a flipped coordinate system in the view, the only solution we've found to work was to let the view host its layer (which nothing ever gets drawn into), put our content in our own layers in a flipped layer (using sublayerTransform) and add the field editor with addSubview: (as a peer, atop our layers). Other approaches end up not resizing correctly, or drawing the field editor upside down. Radar #6503347 has some details of what we've tried.

To me it seems that life would be vastly easier if NSView would just set sublayerTransform to a flipping transform if -isFlipped returned YES. Instead, NSView seems to maintain a non-flipped fiction for its coordinate system and then has private code on the compositing and resizing paths to adjust the coordinates.

The alternative, which is primarily for use if you need AppKit to continue to draw to the view's layer, is to override -setLayer: to do any required setup for your layer tree. So what you would do is check if the incoming layer is non-nil, and if it is, make any changes to that layer (including adding sublayers) at that point.

This is the approach we settled on after some trial and error and it is mostly working pretty well, though we still have a few glitches to fix up.

-tim

_______________________________________________

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