Re: Setting typing attributes in NSTextView
Re: Setting typing attributes in NSTextView
- Subject: Re: Setting typing attributes in NSTextView
- From: Dave Camp <email@hidden>
- Date: Wed, 6 Apr 2005 08:54:31 -0700
On Apr 5, 2005, at 5:55 PM, Jose Antonio Ortega wrote:
I'm using a delegate to modify the text attributes that get inserted
in an NSTextView by means of
textView:shouldChangeTextInRange:replacementString:
Inside the delegate method, I'm modifiying directly the text storage.
For instance, when the text storage would end being *FOO*, I'm
inserting just FOO, and setting its attributes to bold. Accordingly,
my delegate method returns NO. So far so good. The text gets fontified
and the insertion point is at the correct place (after the last O in
the running example).
But now, I want, when the user keeps on typing, the font to be the
same as before the bold replacement. I.e., I want to avoid NSTextView
noticing that FOO is bold and inserting the next character in bold too
[1]. I've tried to set the typing attributes just after I modify FOO,
but to no avail: next time
textView:shouldChangeTextInRange:replacementString: gets called, the
typing attributes are those of the character before the current
insertion point. Looks like the typing attributes are reassigned
somewhere in between succesive calls to the delegate method, but I
don't know when or where.
I've also tried to capture the typing attributes modified notification
and reset them there (with the obvious workaround for the also obvious
potential infinite loop). No luck again.
I suspect I am missing something obvious here... any hints?
Try:
[textView setTypingAttributes:attributesDict];
Dave
-
In English, every word can be verbed.
_______________________________________________
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