• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Undo manager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo manager


  • Subject: Re: Undo manager
  • From: Lorenzo <email@hidden>
  • Date: Wed, 06 Apr 2005 15:28:16 +0200

Hi,
I habe been trying 2 points where to create the undoManager with

    gMyUndoManager = [[NSUndoManager alloc] init];

    1. in the awakeFromNib of an NSObject which is the window's delegate.
    2. in the awakeFromNib of the window subclass itself.

Same result: the undo works, but the Undo and Redo menu item titles report
all the time a simple "Undo" and "Redo". And more, the Undo and Redo
commands are always enabled.
I have found that the problem is related to the fact that the window is
subclassed. In fact, if I don't subclass the window, everything works fine.
When I subclass the window I also override the method validateMenuItem
because I need that. So, now in order to see the complete Undo menu item
title and to activate and deactvate these menu items now I have to add these
code lines in the validateMenuItem method.

- (BOOL)validateMenuItem:(NSMenuItem*)theItem
{
    int tag = [theItem tag];
    switch(tag){
        case kMenuTagEditUndo :
            if([[self undoManager] canUndo]){
                [theItem setTitle:[[self undoManager] undoMenuItemTitle]];
                return YES;
            }
            else return NO;
        break;

        // other cases...
    }
    return YES; // this caused the 2 menu ites were always enabled
    // now it is return NO;
}


The PROBLEM now is that the method undoMenuItemTitle returns a string
starting with a "&" (amazing, why?) so I get something like
    "&Undo Move Object"
    "&Redo Move Object"

This seems to be a Cocoa bug. Anyway, why should I manage the undo menu
items by myself? Just because I override the validateMenuItem method?


Best Regards
--
Lorenzo
email: email@hidden

> From: Jonathon Mah <email@hidden>
> Date: Wed, 06 Apr 2005 20:59:04 +0930
> To: Lorenzo <email@hidden>
> Cc: Cocoa List <email@hidden>
> Subject: Re: Undo manager
>
> On 6 Apr 2005, at 20:53, Lorenzo wrote:
>
>> Also, I have seen that, when I launch the application, the menus
>> "Undo" and
>> "Redo" are deactivated. This is right. But when I activate that window
>> (even
>> clicking on its window bar), the "Undo" and "Redo" menu items become
>> activated. And no action (obvious) is performed when I call them. Why?
>
> When/where are you creating the undo manager?
>
>
> Jonathon Mah
> email@hidden
>

 _______________________________________________
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

  • Follow-Ups:
    • Re: Undo manager
      • From: Jonathon Mah <email@hidden>
References: 
 >Re: Undo manager (From: Jonathon Mah <email@hidden>)

  • Prev by Date: Re: WWDC 2005 - Is the value worth the price? (OT)
  • Next by Date: Re: WWDC 2005 - Is the value worth the price? (OT)
  • Previous by thread: Re: Undo manager
  • Next by thread: Re: Undo manager
  • Index(es):
    • Date
    • Thread