There remains an issue. NSTextViews underneath the drawing view don't respond to key events. Text can be selected though, but the highlight color of selected text is grey, as if the textview was not first responder and keyview. Any other control works correctly though, also textfields.
Am 31.10.2011 um 00:07 schrieb Alexander Reichstadt:
> Thanks much. I ended up subclassing an NSView to draw the required things, subclassed another view to be the containing superview and hold controls, and override in the containing view the addSubview method to always have it call super and also add the drawing view-subclass at the end. That way the view is always added on top of all others. In the given scenario the containing superview dynamically loads subviews anyway, so overriding addSubview seems to be the easiest path.
> Am 30.10.2011 um 22:06 schrieb Jens Alfke:
>> On Oct 30, 2011, at 12:46 PM, Alexander Reichstadt wrote:
>>> given a custom NSView using drawRect to draw, say, a blue rectangle, controls inside that view are always in front of the blue rectangle. Is there a way to draw above controls with drawRect? Also putting a view with controls inside another view that draw in drawRect doesn't change that. Like textfields, they are always above drawn content. How does one draw above controls?
>> 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. (But layer-backing views brings its own visual issues, so this may not work out for you.)
>> Another approach is to subclass the control (or its cell class) and customize its drawing.
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