Re: Setting alignment of NSTextView programmatically [SOLVED]
Re: Setting alignment of NSTextView programmatically [SOLVED]
- Subject: Re: Setting alignment of NSTextView programmatically [SOLVED]
- From: Douglas Davidson <email@hidden>
- Date: Mon, 18 Feb 2008 15:14:08 -0800
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
_______________________________________________
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