My validateMenuItem method is never being called for my undo: and redo: menu items, leaving them permanently disabled.
From Apple's doc, "Enabling Menu Items": http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MenuList/Articles/EnablingMenuItems.html#//apple_ref/doc/uid/20000261-BAJBFGED > If the menu item’s target is not set (that is, if it is nil—typically if the > menu item is connected to First Responder) and the NSMenu object is not a > contextual menu, then NSMenu uses the responder chain (described in About the > Responder Chain) to determine the target. If there is no object in the > responder chain that implements the item’s action, the item is disabled. > > If there is an object in the responder chain that implements the item’s > action, NSMenu then checks to see if that object implements the > validateMenuItem: or validateUserInterfaceItem: method. If it does not, then > the menu item is enabled. If it does, then the enabled status of the menu > item is determined by the return value of the method. Going through these requirements, it appears my app is fulfulling all of them. My undo menu item has its Sent Action set to undo: in First Responder. First Responder at the time of the anomaly is an NSDocument called myQuestionnaireEditor. This can be verified because the Cut and Paste menu items also have their Sent Actions set to First Responder, and validateMenuItem method in myQuestionnaireEditor is called for them as expected. myQuestionnaireEditor does have a method for implementing undo: -(IBAction)undo:(id) sender { [[self undoManager] undo]; } myQuestionnaireEditor does implement validateMenuItem: - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { NSLog(@"validateMenuItem - %@", [menuItem title]); BOOL returnValue = NO; if ([menuItem action] == @selector(undo:)) { return [[self undoManager] canUndo]; } {......} return [super validateMenuItem:menuItem]; } The NSLog output shows that validateMenuItem **is never called** for the undo: menu item. Yet is *is called* for copy:, cut:, paste:, etc. How can I fix this? Thanks very much in advance to all for any info. _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
