On Aug 22, 2012, at 5:21 PM, Koen van der Drift <[email protected]> wrote:
> I'd like to add some custom text highlighting to my NSTextView, so I added > the following code to the NSTextView init method: > > CALayer *aLayer = [CALayer layer]; > [self setWantsLayer: YES]; > [self setLayer: aLayer]; This isn't going to work. The nib loading machinery enumerates all your views and calls -setWantsLayer: after it has initialized all of them. Put this code in -awakeFromNib instead. (Do you really need to subclass NSTextView here?) > > > Then I add the highlighting for a particular text range (aRange): > > self.layer.backgroundColor = CGColorCreateGenericRGB (0.2, 0.2, 0.1, > 1.0); > self.layer.frame = [self.layoutManager boundingRectForGlyphRange: > aRange inTextContainer: self.textContainer]; > > But it looks all garbled for the while view, not for the range, and I see the > Xcode window text behind it. Where is this code? I don't think it does what you think it does. Did you also remember to turn in later-backing for the text view's enclosing scroll view? --Kyle Sluder _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
