On Aug 21, 2011, at 11:13 , Luc Van Bogaert wrote:

> I have found a way to get what I want using the sharedDocumentController 
> object and the current document's list of windows.
> 
> But actually, I'd prefer using 'validateUserInterfaceItems' as you suggest, 
> except that some of the menu items that I want to change, are actually 
> submenu's that don't send a message to my target object. So how would those 
> get validated if they aren't using the target-action mechanism?

So what is the purpose of the submenu items if they don't have an action?

Not that it matters much. The only way to display the submenu is to display the 
menu item (well, the menu item's menu), so the menu item validation is going to 
be called first. You can use validation of the menu item to trigger updating of 
or contextualizing the submenu. That's the ordinary way, too.

I forgot to say in my earlier response:

You probably don't (in general) want to make a window controller the delegate 
of a *menu*, because this means the window controller is going to need 
knowledge of the structure of the menus themselves, and that's not desirable -- 
if you moved an item to a different menu, you'd likely have to change the 
window controller too. The 'validateUserInterfaceItem:' mechanism divorces the 
menu item behavior from the menu structure. It also (potentially) integrates 
validation across menu-bar menus, context menus, popup button menus and toolbar 
items. It's "really" the action being validated, not the UI representation of 
the action, if you want to think of it that way.

The example you raised, though, where a submenu changes in response to (say) 
the document state *is* an example of the window controller needing knowledge 
of the menu structure (part of it, anyway).


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to