Re: Cocoa Text System: How to determine the caret position?
Re: Cocoa Text System: How to determine the caret position?
- Subject: Re: Cocoa Text System: How to determine the caret position?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 24 Jun 2008 08:14:50 -0700
On Jun 23, 2008, at 7:30 PM, Graham Cox wrote:
Yes, fair enough the problem is more complicated than I realised - I
guess I assumed that insertion points were always in between glyphs
but of course with ligatures etc. that isn't the case.
Going back to the OP's original reason for this, My feeling is that
he's going about it the wrong way. Core Text isn't a text editing
framework, it's a text layout framework. I thought that using
Cocoa's text system you can get text editing as well as layout for
arbitrary text containers including text on a path or vertical text.
However it's one thing to say it's possible and another to suggest
how to do it, and I don't have the expertise to do that. But
reinventing your own text editor from scratch seems like a lot of
unnecessary work.
Yes, reinventing your own text editor is an enormous amount of work.
Using a custom text container will get you text laid out within a
shape, though, which is not the same thing as text laid out on a
path. Subclassing NSLayoutManager and overriding the drawing methods
would enable you to take text laid out conventionally in lines and
draw it on a path--cf. the CircleView example--but for editing
purposes one would need more, such as hit-testing, drawing highlights,
maybe drawing underlines, etc. That might be possible by overriding
more methods in an NSLayoutManger subclass, and maybe an NSTextView
subclass, but I haven't tried it. Vertical text has its own
challenges--a minimal version could be obtained by simply rotating
glyphs 90 degrees and rotating the view 90 degrees the other way, but
most clients would probably want more than that.
Douglas Davidson
_______________________________________________
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