Re: Text Handling Questions
Re: Text Handling Questions
- Subject: Re: Text Handling Questions
- From: Douglas Davidson <email@hidden>
- Date: Mon, 4 Mar 2002 12:28:01 -0800
On Monday, March 4, 2002, at 11:52 AM, Nicholas Shanks wrote:
I want to call -[NSMutableParagraphStyle
setLineBreakMode:NSLineBreakByCharWrapping], but can't find how to get
the NSMutableParagraphStyle object from my NSTextView. Does anyone here
know the answer?
For the second, my NSTextView subclass was using a delegate to change
the text ( setText: ) after the user typed, and returning NO to should
change text. The drawback here is this doesn't work with pasted text or
the delete key, and I can't simply manipulate the text buffer (because
I don't know how). I want delete to work one word at a time (forwards &
backwards)
, not one character at a time, and when the user types any other key, I
want to be able to insert zero or more characters into multiple
NSTextViews. Any pointers?
There is not just one paragraph style to a text view. The paragraph
style is an attribute of the text, like the font or the color, and it
may be set on a range of characters; however, attribute fixing does
force the paragraph style to remain constant over each paragraph in the
text. Set a paragraph style as an attribute with the
NSParagraphStyleAttributeName key.
To manipulate the text buffer, you need to work with your
NSTextStorage. NSTextStorage is a special subclass of
NSMutableAttributedString, so the first thing to do is to learn how to
manipulate NSMutableAttributedStrings. That will allow you to alter
attributes, insert and delete text, etc.
Non-text keypresses like delete will come to your delegate via
textView:doCommandBySelector: with the selector being e.g.
@selector(deleteBackward:).
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.