FROM : Dave Camp
DATE : Wed Apr 06 17:54:31 2005
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.
DATE : Wed Apr 06 17:54:31 2005
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.
| Related mails | Author | Date |
|---|---|---|
| Jose Antonio Orteg… | Apr 6, 02:55 | |
| Dave Camp | Apr 6, 17:54 | |
| Jose Antonio Orteg… | Apr 7, 02:31 |






Cocoa mail archive

