Re: Setting alignment of NSTextView programmatically [SOLVED]
Re: Setting alignment of NSTextView programmatically [SOLVED]
- Subject: Re: Setting alignment of NSTextView programmatically [SOLVED]
- From: Ken Worley <email@hidden>
- Date: Wed, 20 Feb 2008 10:59:20 -0700
On Feb 18, 2008, at 4:14 PM, Douglas Davidson wrote:
On Feb 15, 2008, at 12:35 PM, Ken Worley wrote:
Here's the solution I've got for now that works in the sample
project:
Take out the alignRight message in the above and replace it with
this:
NSParagraphStyle* tStyle = [NSParagraphStyle defaultParagraphStyle];
NSMutableParagraphStyle* tMutStyle = [tStyle mutableCopy];
[tMutStyle setAlignment:NSRightTextAlignment];
[codeBasedTextView setDefaultParagraphStyle:tMutStyle];
Oddly enough, it does not work if I start with [codeBasedTextView
defaultParagraphStyle]. Also, I still can't understand why simply
calling alignRight doesn't work since it's supposed to apply to all
text if the receiver is plain text...
Here is what is going on in this case:
The text view is set to be non-editable. The method -alignRight: is
the UI action for right-aligning text; since user actions do not
affect non-editable text, this method does not affect non-editable
text views. If you want to right-align programmatically, you can
use setAlignment:NSRightTextAlignment instead, or modify the text
storage directly.
Douglas Davidson
Thanks very much for the help. The difference between those two
methods was lost on me before.
Ken
--
Ken Worley
Software Engineer, Tiberius, Inc.
_______________________________________________
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