Re: Issues with NSTextView and undoing attributes - Solved (I think)
Re: Issues with NSTextView and undoing attributes - Solved (I think)
- Subject: Re: Issues with NSTextView and undoing attributes - Solved (I think)
- From: Scott Lehman <email@hidden>
- Date: Sun, 5 Mar 2006 22:15:20 -0800 (PST)
I think the culprit was non-lazy attribute fixing in
the text storage. I wasn't expecting a text change to
the start of a paragraph to cause the prior
paragraph's style to extend to this entire paragraph.
Making the fixing lazy provides the proper result.
I take it I should always be careful to apply
paragraph styles to entire paragraphs at a time to
avoid any similar issues?
Scott
--- Scott Lehman <email@hidden> wrote:
> I found a part of the issue where I was replacing
> text
> in the text storage with an attributed string
> (without
> the matching style), however the programmatically
> applied style doesn't get removed from all text when
> undoing now.
>
> In the operation, I'm actually iterating thru
> paragraphs of the selection, making multiple calls
> to
> shouldChangeTextInRange:replacementString: (changing
> characters and then setting attributes) for each
> paragraph with a didChangeText after each one. I
> may
> try grouping all changes together into a single
> large
> change, but should that be necessary? Should
> didChangeText be called only once for a series of
> changes?
>
> Thanks,
>
> Scott
>
> --- Scott Lehman <email@hidden> wrote:
>
> > Hi all,
> >
> > I have an NSTextView subclass and in one
> operation,
> > I
> > programmatically apply a new paragraph style to a
> > paragraph to change spacing, using
> > shouldChangeTextInRange: replacementString: to
> > register for undo.
> >
> > When I undo the action, the style applied in the
> > operation is undone, but the paragraph style that
> > was
> > present before the operation does not get
> restored.
> > The previous style was set by the NSTextView
> itself
> > during typing, rather than programmaticaly.
> >
> > Is there something else that needs to be done to
> > ensure the original attributes get restored? The
> > best
> > solution I can think of right now is to take over
> > the
> > undo registration of the operation, though I
> suspect
> > NSTextView can take care of it for me - assuming I
> > did
> > everything else right :)
> >
> > Thanks,
> >
> > Scott
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> > protection around
> > http://mail.yahoo.com
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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