Re: Overwriting text in an NSTextView?
Re: Overwriting text in an NSTextView?
- Subject: Re: Overwriting text in an NSTextView?
- From: Douglas Davidson <email@hidden>
- Date: Thu, 15 Jun 2006 10:52:59 -0700
On Jun 15, 2006, at 9:39 AM, Keith Blount wrote:
Is there a way to have letters overwrite one another
using the NSTextView text system? Eg., so that I could
merge a "g" with an "X" (in my emulator, I would like
it so that if the user goes back and types, instead of
the text getting inserted and moving text after it
forward, it will overwrite the old text). Not sure if
this is at all possible, but I'm sure I read somewhere
ages ago about something like this (probably imagining
it).
Well, usually this is something we try to avoid. :) You can, if you
like, directly manipulate the glyphs in the layout manager--for
example, inserting new glyphs at arbitrary locations in the text and
arbitrary positions. You need to be a little careful about it,
because it's easy to shoot yourself in the foot this way. You should
think about how you want this to work in general, though--the Cocoa
text system is based on taking a text document (NSTextStorage) and
from it producing a set of glyphs and positions in the layout
manager. Just how do you plan on representing your overstrikes in
the text document?
If you represent them as characters, then maybe you can use a
typesetter subclass to arrange the positioning you want--that would
probably be the most robust way to do it. If the overstrikes are
represented as attributes, then perhaps you don't need to insert
glyphs in the layout manager--maybe you just need to do some extra
drawing. I showed an example of something along those lines at WWDC
in 2003, my "AnnotatedTextDemo". I can make that code available if
you want it.
Douglas Davidson
_______________________________________________
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