(as you type) spell checking of an attributed string
(as you type) spell checking of an attributed string
- Subject: (as you type) spell checking of an attributed string
- From: "email@hidden" <email@hidden>
- Date: Mon, 29 Jun 2009 18:31:13 -0700
in my app, i use a NSTableView to let the user specify
headers/footers for use in reports. a row in the table corresponds to
a single header/footer line. a single header/footer line is an
NSAttributedString, and i allow the user to specify the text and font
and size and text color. additionally, the user can select "tags"
from a popup to insert tags in the line that get evaluated when the
report is printed. (these tags correspond to things like the print
date, user's name, report name, etc.) my model (persistent copy) of a
header/footer line stores these tags as a 4 character sequence: %XX%
(where XX corresponds to the particular tag). for display in the
table, i replace the 4 character sequence with:
\x0001<EXPANDED VALUE>\x0001
ie, a unicode "1", a string meaningful to the user, a unicode "1".
this expanded sequence is given its own custom attribute and the
string is displayed with a unique background color. (i suspect this
is sorta like a token string, but my implementation pre-dates my
knowledge of NSTokenField).
this has worked well for me, and i successfully deal with my tags as
words as far as selection and drag and drop.
now i'd like to be able to support spell checking when the user is
specifying header/footer lines. and i'd like to be able to support
both manually requested spell checking and continuous/as-you-type
spell checking. and when performing either form of spell checking, a
tag should be treated as a series of space characters.
as i already have my own custom field editor for the table, i believe
by overriding of -[NSText checkSpelling], i can get user requested
spell checking to work. i would simply perform the appropriate call
to NSSpellChecker to check a string in which i've replaced my tags
with spaces, and i could set the spell state and selection as needed.
but i can't think of anyway to have continuous spell checking treat
my tags as a sequence of spaces. can anyone (Mr. Davidson? :-)) offer
some suggestions?
one thing i thought of thus far is to have the spell checker learn
and unlearn my sequences whenever my custom field editor becomes the
first responder and the user has requested continuous spell checking.
this almost works, but fails if the user doesn't have a word break
character between my tag and his/her typing.
thanx for any help/advice/suggestions/any thing,
ken
_______________________________________________
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