Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSTextView formatting

NSTextView formatting
Thread Tools
Junior Member
Join Date: Jul 2002
Location: Australia
Status: Offline
Reply With Quote
Jul 21, 2003, 05:42 AM
 
Hey all,
I just got a quick question is there any way of formatting a word/sentance/letter (colour, text, bold, italics etc) in a NSTextView, I know this can't be achieved by just drag and dropping it in Interface Builder.... so.. anyone got any ideas?
     
Mac Elite
Join Date: Jul 2002
Status: Offline
Reply With Quote
Jul 21, 2003, 08:05 AM
 
I am so much of a newbie at this... but maybe "%" followed by a formatting tag like you would with NSCalendarDate?
-"I don't believe in God. "
"That doesn't matter. He believes in you."

-"I'm not agnostic. Just nonpartisan. Theological Switzerland, that's me."
     
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Jul 21, 2003, 12:49 PM
 
I do not know what attributes you are trying to set, but you might want to look at NSText, which is the super class of NSTextView. Some methods of interest are:

setSelectedRange: - you can use this to set the selection of characters you want to change.

setTextColor:
setTextColor:range:
setFont:
setFont:range:

In NSTextView you can replace a set of characters with a different NSAttributedString formated how you like with the insertText: method. You can also use NSTextView's setSelectedRange: method with the setSelectedAttributes: method you change a limited set of attributes (ex. color).

Hope this helps a little.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jul 21, 2003, 05:36 PM
 
Also, since NSTextStorage inherits from NSMutableAttributedString, you can use any attributed string methods to alter the view's text storage directly.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:11 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2