Setting typing attributes in NSTextView
Setting typing attributes in NSTextView
- Subject: Setting typing attributes in NSTextView
- From: Jose Antonio Ortega <email@hidden>
- Date: Wed, 6 Apr 2005 02:55:28 +0200
Hello.
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?
Thanks for any help.
Cheers,
José
[1] Basically, I'm trying to reproduce the behaviour of, say,
Format->Bold menu item when the cursor is located just after a bold
character.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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