Skip navigation.
 
mlRe: Ephemeral Changes
FROM : Gerriet M. Denkmann
DATE : Wed Mar 26 11:26:44 2008

On 26 Mar 2008, at 04:07, Sherm Pendley wrote:
> On Tue, Mar 25, 2008 at 10:07 PM, Gerriet M. Denkmann 
> <<email_removed>> wrote:
>
> On 25 Mar 2008, at 23:12, Graham Cox wrote:
> > There may be a simpler way, but this is what occurred to me when I
> > read this:
> >
> > Subclass NSTextView and override -changeFont: -changeAttributes:
> > and any other "ephemeral" method. Turn off the undo manager using -
> > disableUndoRegistration, call super, then turn it back on again.
> >
>
> I have to apologize for not stating my problem more clearly. Let's
> try again:
>
> I do want to see "Undo Set Font" or "Redo Paste Font" etc. in my Edit
> menu. So disabling the undo manager is probably not the right thing.
>
> You could override the "epemeral" methods and call [self 
> updateChangeCount:NSChangeUndone] after calling super. That would 
> leave the operation on the undo stack, but leave the document's 
> change count, um... unchanged. :-)

This seems to be an excellent idea.

I have implementd in MyTextView:

- (void)changeFont:(id)sender
{
   [ super changeFont: sender ] ;        
   GmdDocument *docum = [ self delegate ];    
   [ docum updateChangeCount: NSChangeUndone ];
}

- (void)pasteFont:(id)sender  .... same ....

Now I can set the font via:
Format ► Font ► Past Style  or via:
Format ► Font ► Show Fonts and selecting some font in the Font Panel
without the document getting dirty.
Very good so far.

I also can use Edit  ► Undo Set (or Paste) Font but now the document 
gets dirty. Very bad. Also: the complete text gets selected.
So what else do I have to implement? I tried setFont: and 
setFont:range:, but these seem never to be called.
How does the NSUndoManager undo my font changes?

>
>
>
> Or, you could keep track of the "real" changes yourself, and 
> override -isDocumentEdited with your own implementation.

This would be more work - and also I am not at all sure what to 
override.


Kind regards,

Gerriet.

Related mailsAuthorDate
mlEphemeral Changes Gerriet M. Denkman… Mar 25, 18:48
mlRe: Ephemeral Changes Graham Cox Mar 25, 23:12
mlRe: Ephemeral Changes Gerriet M. Denkman… Mar 26, 03:07
mlRe: Ephemeral Changes Sherm Pendley Mar 26, 04:07
mlRe: Ephemeral Changes Gerriet M. Denkman… Mar 26, 11:26
mlRe: Ephemeral Changes Graham Cox Mar 26, 22:56
mlRe: Ephemeral Changes Jens Miltner Mar 27, 09:50
mlRe: Ephemeral Changes Gerriet M. Denkman… Mar 27, 11:57
mlRe: Ephemeral Changes Jens Miltner Mar 27, 14:46
mlRe: Ephemeral Changes Gerriet M. Denkman… Mar 27, 18:44
mlRe: Ephemeral Changes Gerriet M. Denkman… Mar 27, 18:48