Re: Document-based app: UI item validation
Re: Document-based app: UI item validation
- Subject: Re: Document-based app: UI item validation
- From: Luc Van Bogaert <email@hidden>
- Date: Sun, 21 Aug 2011 21:22:00 +0200
On 21 Aug 2011, at 20:40, Quincey Morris wrote:
> 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?
What I was trying to explain: I want to change the title of a menuitem, which opens a submenu. Of course the menu items in that submenu all have actions, but the action of the menuitem I'm trying to change is '' submenuAction".
So, in order to validate my menuitem in the normal way, do I understand correctly that I would have to subclass NSMenu and assign this new class to the menu that is opened by my menuitem, and that I could implement 'validateUserInterfaceItems' in my new subclass ?
>
> 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 think I understand, but I'm not yet clear on how I would trigger the validation of my menuitem, since its action is not implemented in any of my classes, instead it's implement by NSMenu.
>
> 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.
>
Thank you for this explanation.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden