Re: Setting the Line Height/ Line Spacing in an NSTextView.
Re: Setting the Line Height/ Line Spacing in an NSTextView.
- Subject: Re: Setting the Line Height/ Line Spacing in an NSTextView.
- From: Joshua Garnham <email@hidden>
- Date: Sat, 2 Jan 2010 18:15:47 +0000 (GMT)
Thanks that works now!
________________________________
From: Paul Sanders <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: email@hidden
Sent: Sat, 2 January, 2010 15:03:11
Subject: Re: Setting the Line Height/ Line Spacing in an NSTextView.
Yep, that looks ok. I think pS is probably being returned as
nil. You can check this in Xcode. In which case, you can add:
if (pS == nil)
pS = [NSParagraphStyle defaultParagraphStyle];
Paul Sanders.
----- Original Message -----
From: Joshua
Garnham
To: Paul Sanders
Cc: email@hidden
Sent: Saturday, January 02, 2010 2:52 PM
Subject: Re: Setting the Line Height/ Line Spacing in an
NSTextView.
Thanks for the Guide/Walkthrough, Here's what I have come up with from
that:
NSDictionary *tA = [textView typingAttributes];
NSMutableDictionary *tAM = [tA mutableCopy];
NSParagraphStyle *pS = [tAM
objectForKey:NSParagraphStyleAttributeName];
NSMutableParagraphStyle *pSM = [pS mutableCopy];
[pSM setMinimumLineHeight:spacing];
[pSM setMaximumLineHeight:spacing];
[tAM setObject:pSM forKey:NSParagraphStyleAttributeName];
[textView setTypingAttributes:tAM];
[tAM release];
[pSM release];
All of it seems ok in XCode but when I run it I get
an error in the debugger saying
***
-[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key:
NSParagraphStyle)
It seems to be saying that the
NSMutableParagraphStyle is empty. I'll take a look at Aaron's Book, Thanks.
Josh
________________________________
From: Paul Sanders
<email@hidden>
To: Graham Cox
<email@hidden>; Joshua Garnham
<email@hidden>
Cc: Cocoa-Dev List
<email@hidden>
Sent: Sat, 2 January, 2010
11:04:52
Subject: Re: Setting
the Line Height/ Line Spacing in an NSTextView.
Well, I have to
say Graham has a point there, and I'm not going
to write your code for you,
but what I do goes something like
this:
1. Get the current
typing attributes from my NSTextView (as an
NSDictionary)
2.
Make a mutable copy (as an NSMutableDictionary)
3. Retrieve the
current NSParagrahpStyle from the dictionary
(using
NSParagraphStyleAttributeName as a key)
4. Make a mutable copy of
that (as an NSMutableParagraphStyle)
5. Adjust this as desired
(refer to docs)
6. Add it to the NSMutableDictionary (again with
key
NSParagraphStyleAttributeName)
7. Pass the dictionary to
NSTextView's setTypingAttributes
method
8. Release your mutable
copies
You can do something similar (using NSFont and
NSFontAttributeName) if you want to change the font (which might
be what
you're after, I'm not sure).
If none of this makes any sense to you, you
need to do some
background reading (it's not something you can do in 5
minutes)
and then write youself a little test program. Mine is called
Cocoa Testbench, and it taught me a lot.
As an aside, I remember when
I first started learning Cocoa how
tiring I found it, mentally (I am not the
youngest of spring
chickens). There is a lot to know. I think
it's Hillegass who
recommends getting plenty of sleep. His book "Cocoa
Programming
for Mac OS X" might be worth buying (that will be $5 please
Aaron :).
Paul Sanders
----- Original Message -----
From:
"Graham Cox" <email@hidden>
To:
"Joshua Garnham" <email@hidden>
Cc:
"Cocoa-Dev List" <email@hidden>
Sent:
Saturday, January 02, 2010 10:13 AM
Subject: Re: Setting the Line Height/
Line Spacing in an
NSTextView.
On 02/01/2010, at 6:57 PM,
Joshua Garnham wrote:
> How would I use
that?
RTFM:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/TextArchitecture.pdf
--Graham
_______________________________________________
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
_______________________________________________
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