Re: Strange behaviour of text insertion in NSTextView
Re: Strange behaviour of text insertion in NSTextView
- Subject: Re: Strange behaviour of text insertion in NSTextView
- From: Jeremy Dronfield <email@hidden>
- Date: Mon, 19 Apr 2004 18:44:30 +0100
On 19 Apr 2004, at 5:40 pm, Douglas Davidson wrote:
On Apr 19, 2004, at 8:26 AM, Jeremy Dronfield wrote:
I have a text view which allows the user to insert text directly from
a file. It's done very simply:
fileText = [[NSAttributedString alloc] initWithPath:fromPath
documentAttributes:NULL];
[textView insertText:fileText];
The strange behaviour is this: when the source file at fromPath is in
MS Word doc format, the insertion dirties the document and can be
undone, but when the source is rtf or rtfd, it slips past the text
view's undo manager completely unobserved. The document stays clean,
and the insertion can't be undone. Has anyone else come across this
behaviour, and can anyone explain it?
I don't have an explanation offhand, but I can tell you that
insertText: is intended as the funnel point for user typing, and its
behavior is not likely to be appropriate for any other use.
Yes, I know I was being a bit naughty here. This was one of a sequence
of approaches, in which I thought I'd give insertText: a try to see
what happened. I was intrigued by this anomaly. I've since replaced it
with insertAttributedString: applied to the textStorage. Trouble is,
this method *never* dirties the document...
Thanks for the reply. It's interesting in itself that there's no
obvious explanation.
Regards,
Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.