• 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
Rounded selection rectangles in NSTextView (was: NSBezierPath geometry question...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rounded selection rectangles in NSTextView (was: NSBezierPath geometry question...)


  • Subject: Rounded selection rectangles in NSTextView (was: NSBezierPath geometry question...)
  • From: Keith Blount <email@hidden>
  • Date: Wed, 13 Apr 2005 11:06:44 -0700 (PDT)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

Many thanks for your reply and your offer of
experimenting with the code - much appreciated.

To recap, this is what I am trying to do: I have an
NSTextView subclass and I want to highlight certain
ranges of text using rounded rectangles. However,
because thes ranges may spill over more than one line,
the selections might not just be straightforward
rectangles; rather, they may be compound shapes made
up from several rectangles returned by
NSLayoutManager's rectArrayForCharacterRange:... This
whole compound shape needs its corners rounding, and
this is where I am running into trouble (rounding the
corners of a simple rectangle is relatively
straightforward thanks to the many examples in the
archives and elsewhere).

I have got so far, and the results aren't too bad, but
there are still artefacts - in particular, the top
corners seem more rounded than the bottom ones
(perhaps my radius calculations are off?).

Anyway, for anyone interested - Jonathon in
particular, thank you - here is a sample project with
what I have achieved so far:

http://www.rumramruf.com/BezierPathTest.zip

This provides a simple subclass of NSTextView
(BezierTextView) which overrides
drawViewBackgroundInRect: to draw rounded highlighting
rectangles around ranges of text that have a bold font
(in reality I would be using this to highlight ranges
of text with a custom note attribute attached to them,
but thought I would keep it simple here). Note that I
have yet to check to see if there are only two
rectangles that don't touch, in which case two
separate rectangles should be drawn (at the moment
they are attached by an ugly line).

Many thanks to anyone who has the time to take a look
and offer suggestions for improvements/spots any
mistakes I am making.

Thanks again and all the best,
Keith

--- Jonathon Mah <email@hidden> wrote:
> On 12 Apr 2005, at 07:54, Keith Blount wrote:
>
> > In a possibly vain attempt to return to my
> original
> > question, if anyone could help, I would be very
> > grateful. :)
>
> Hi Keith,
>
> I've just been playing with Bezier curves myself
> today, and I'm
> interested in your problem. If you have time,
> though, could you send
> over a small Xcode project? Otherwise I could
> suggest things all day
> without knowing if they work or not. But if you do,
> I _promise_ I'll
> find the errors with you!
>
>
> Jonathon Mah
> email@hidden
>
>



__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Rounded selection rectangles in NSTextView (was: NSBezierPath geometry question...)
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: OT : Is the Jaguar user base large enough to still support it?
  • Next by Date: Determining if a special input method is active - was Detecting double byte input
  • Previous by thread: Re: XSLT
  • Next by thread: Re: Rounded selection rectangles in NSTextView (was: NSBezierPath geometry question...)
  • Index(es):
    • Date
    • Thread