Re: Saving NSFonts and changedFont: trouble
Re: Saving NSFonts and changedFont: trouble
- Subject: Re: Saving NSFonts and changedFont: trouble
- From: Todd Ransom <email@hidden>
- Date: Wed, 9 Apr 2008 12:55:02 -0400
Thomas,
The responder chain is really the key to your question. The text view
is getting the changeFont: message instead of your controller once it
gets focus. How are you implementing the control that lets your user
change fonts? Do you have a separate button/control for that or are
you relying on the user to do it using the font panel?
If you want the user to do it using the font panel you can either
override -[NSTextView changeFont:] to save the value and call super's
implementation or you can implement the delegate method
textView:shouldChangeTextInRange:replacementString: When the
replacement string passed into this method is nil it means only
attributes were changed in the text view. If it is an empty string it
means some text was removed. Note that there are also other methods in
NSTextView for other changes that you may also need to override
(changeColor:, changeAttributes:) if you want to capture more than
just font changes.
If you have a separate control for this you should not be messing with
these methods at all, just write a method that will save the new font
and apply to the text view.
Todd Ransom
Return Self Software
http://returnself.com
On Apr 9, 2008, at 10:25 AM, Thomas Backman wrote:
Hmm, I just noticed that if I do
[mainWindow makeFirstResponder:textView];
It never works. In other words, when the text view IS the first
responder, it breaks. Otherwise, it seems to work great.
I'll be honest, I don't understand the responder chain, and I'm
about to read through cocoa fundamentals, but: could somebody give
me a hint how to intercept/receive the message sent directly to the
textview?
TIA
/Thomas
On Apr 8, 2008, at 4:41 PM, Thomas Backman wrote:
Hey everybody. I'm working on a small app - to make the post
shorter, lets just say that it displays (plain) text, but I want
the user to be able to pick the font used (the same font should be
used for all the text).
Right now, I have a changedFont: method in my controller class,
that changes the font successfully, and saves the font+size as a
string and float. First off, is there a better way to save things?
There has to be. Anyway, that wasn't my main question. More
importantly, this does work, until you click in the textview...
When that happens, changedFont: is no longer called, and the font
stays the same.
Why? (It works again after an app restart.)
I've tried setting the textview delegate, and a sharedFontManager
delegate, to my controller. (Not sure about what I'm doing here, as
you might have noticed)
I realize I'm short on info, but I'm not exactly sure what info to
provide, so please ask if you need more.
TIA
Thomas
_______________________________________________
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
_______________________________________________
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