• 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: drawing lines in and NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing lines in and NSTextView


  • Subject: Re: drawing lines in and NSTextView
  • From: Graham Cox <email@hidden>
  • Date: Sun, 01 Apr 2012 11:09:52 +1000

On 31/03/2012, at 11:08 PM, Koen van der Drift wrote:

> I have an NSTextView to which I want to add some lines that connect
> certain words. When the text changes, either by editing, or scrolling,
> that lines should follow the words. I thought about using
> CoreAnimation, but text in a CATextLayer does not appear to be
> editable like the text in an NSTextView (is that correct?).  So, an
> alternative could be to override drawViewBackgroundInRect and use
> NSBezierPaths to draw my lines and I will work on that this weekend.
>
> Any thoughts or suggestions I may have overlooked?


Seems to me you're focusing on the wrong aspect of the problem. The key to this is to track given words' positions as the text is scrolled/reflowed. If you lay out the text yourself (using NSLayoutManager, for example) this is not hard, but if you leave it to something else, such as NSTextView, it may be a lot harder (though NSTextView has a NSLayoutManager of which you can ask questions).

Drawing the lines once you have those positions is relatively easy - NSBezierPaths will work, and are probably the simplest.


--Graham



_______________________________________________

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: drawing lines in and NSTextView
      • From: Douglas Davidson <email@hidden>
References: 
 >drawing lines in and NSTextView (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Order of Finder labels
  • Next by Date: Re: drawing lines in and NSTextView
  • Previous by thread: drawing lines in and NSTextView
  • Next by thread: Re: drawing lines in and NSTextView
  • Index(es):
    • Date
    • Thread