Re: NSTextView backed by core data, undo problems
Re: NSTextView backed by core data, undo problems
- Subject: Re: NSTextView backed by core data, undo problems
- From: Martin Hewitson <email@hidden>
- Date: Fri, 12 Mar 2010 08:38:25 +0100
Thanks, Kyle. I figured the answer would be something like this. OK, then I'll need to rethink the architecture a bit. I was aiming for an Xcode-like interface with potentially multiple views to the same file content, but without using 'updates continuously' this is going to be more difficult to achieve. If anyone has any good suggestions, I'd be delighted to hear them.
Thanks again,
Martin
On Mar 11, 2010, at 8:52 PM, Kyle Sluder wrote:
> On Thu, Mar 11, 2010 at 7:50 AM, Martin Hewitson
> <email@hidden> wrote:
>> The nasty little problem I have is that if I edit the contents of a file via the NSTextView, then do 'undo', the cursor (selection) in the NSTextView jumps to the end of the document, and the scrollview jumps to the top. Almost as if the whole text has been replaced. The only way I can avoid this so far is to set the binding so that it doesn't 'update continuously'. One other symptom is that each undo removes the last character typed, whereas with 'update continuously' off I get the more common behaviour of undoing the last word or at least recent group of actions.
>
> By setting the value continuously you're breaking the text view's undo
> coalescing.
>
> Doing this correctly is not going to be an easy task. You will need to
> learn much about the Cocoa text system. The 30,000ft overview: you
> want to mutate an NSTextStorage hooked up to the text view, rather
> than simply setting a property on the model object. Core Data and KVC
> don't support this pattern natively; you will need to write code, and
> it can get hairy.
>
> --Kyle Sluder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
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