Re: How to draw over a control in an NSView
Re: How to draw over a control in an NSView
- Subject: Re: How to draw over a control in an NSView
- From: Steve Sisak <email@hidden>
- Date: Sun, 30 Oct 2011 22:22:02 -0400
At 7:09 PM -0700 10/30/11, Ken Ferry wrote:
On Oct 30, 2011, at 2:06 PM, Jens Alfke <email@hidden> wrote:
> On Oct 30, 2011, at 12:46 PM, Alexander Reichstadt wrote:
> Subviews are always drawn after their superview, so they are
visually in front of it. You can't change that.
> What you can try is adding a subview, positioning it over the
control, and putting it in front (I think that means later in the
subviews array.) Historically AppKit hasn't handled overlapping
sibling views, but I think that nowadays if you make the parent view
layer-backed it will work.
That's actually slightly reversed. AppKit has supported overlapping
sibling views since 10.5. Layers complicate the story a bit, because
a non-layer backed view can never draw over top of a layer.
Since I happen to be reading the Cocoa View Programming Guide at this
instant, I'll mention that it currently says:
Note: For performance reasons, Cocoa does not enforce clipping among
sibling views or guarantee correct invalidation and drawing behavior
when sibling views overlap. If you want a view to be drawn in front
of another view, you should make the front view a subview (or
descendant) of the rear view.
<http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/WorkingWithAViewHierarchy.html#//apple_ref/doc/uid/TP40002978-CH4-SW16>
It sounds like this section should be updated to reflect current reality.
It might be worth someone submitting a documentation bug on this.
HTH,
-Steve
_______________________________________________
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