• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: text highlighting with CALayer and NSTextVew
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text highlighting with CALayer and NSTextVew


  • Subject: Re: text highlighting with CALayer and NSTextVew
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 23 Aug 2012 08:23:26 -0700

On Aug 22, 2012, at 5:21 PM, Koen van der Drift <email@hidden> 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@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

  • Follow-Ups:
    • Re: text highlighting with CALayer and NSTextVew
      • From: Koen van der Drift <email@hidden>
References: 
 >text highlighting with CALayer and NSTextVew (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: text highlighting with CALayer and NSTextVew
  • Next by Date: Re: text highlighting with CALayer and NSTextVew
  • Previous by thread: Re: text highlighting with CALayer and NSTextVew
  • Next by thread: Re: text highlighting with CALayer and NSTextVew
  • Index(es):
    • Date
    • Thread