• 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: Koen van der Drift <email@hidden>
  • Date: Thu, 23 Aug 2012 07:16:09 -0400

Another update, I guess I love to talk to myself.

I got the drawing part done as follows:


         CALayer  *aLayer = [CALayer layer];
         NSRect r = [self.layoutManager boundingRectForGlyphRange: aRange inTextContainer: self.textContainer];

         aLayer.backgroundColor = CGColorCreateGenericRGB (0.2, 0.2, 0.2, 0.2);		// obviously this will be changed to something nicer
         aLayer.frame = r;
         aLayer.cornerRadius = 6.0f;

         [self.layer addSublayer: aLayer];


There are two problems:

1. the y-location of the layer that is drawn is wrong, I think it has to do with the coordinates being flipped
2. when the range contains a line break, I get the rect for two whole lines, not just the glyphs.


- Koen.



On Aug 23, 2012, at 5:13 AM, Koen van der Drift <email@hidden> wrote:

>
> On Aug 22, 2012, at 8:21 PM, Koen van der Drift <email@hidden> wrote:
>
>>
>>    CALayer *aLayer = [CALayer layer];
>>    [self setWantsLayer: YES];
>>    [self setLayer: aLayer];
>
>
> Turning on CA in IB seems to work instead of adding this code to my view's code.
>
> - Koen.


_______________________________________________

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: Graham Cox <email@hidden>
    • Re: text highlighting with CALayer and NSTextVew
      • From: Graham Cox <email@hidden>
References: 
 >text highlighting with CALayer and NSTextVew (From: Koen van der Drift <email@hidden>)
 >Re: text highlighting with CALayer and NSTextVew (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Sandboxing die.die.die
  • 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