Re: Setting the default font of an NSTextView...
Re: Setting the default font of an NSTextView...
- Subject: Re: Setting the default font of an NSTextView...
- From: Ben Kazez <email@hidden>
- Date: Fri, 7 Apr 2006 11:01:11 -0500
On Apr 7, 2006, at 9:48 AM, Shawn Erickson wrote:
Message: 18
Date: Fri, 7 Apr 2006 07:48:29 -0700
From: "Shawn Erickson" <email@hidden>
Subject: Re: Setting the default font of an NSTextView...
To: "Nick Zitzmann" <email@hidden>
Cc: email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=ISO-8859-1
On 4/7/06, Nick Zitzmann <email@hidden> wrote:
I already searched the archives, and not one person had a solution to
the problem of setting a text view's default font that works. I have
tried the following:
3. Using -[NSTextView setTypingAttributes:]
I am fairly sure that typing attributes is what you want but I believe
you have to reapply them if the selection, etc. changes. Try having a
delegate of that text view respond to
textViewDidChangeTypingAttributes: or possibly
textViewDidChangeSelection: and in one of those reapply the desired
default type attributes. (not tried this myself in any prior project)
This is currently working for me in an NSTextView subclass:
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange
granularity:(NSSelectionGranularity)granularity {
// Set typing attributes every time the cursor is moved.
[self setTypingAttributes:forcedTypingAttributes];
return proposedSelRange;
}
However, the docs for this method say "Override this method to
specialize selection behavior." Since I'm not specializing selection
behavior, maybe it's better to use textViewDidChangeSelection:.
Ben
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden