• 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: Document-based app: UI item validation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Document-based app: UI item validation


  • Subject: Re: Document-based app: UI item validation
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 21 Aug 2011 10:34:22 -0700

On Aug 21, 2011, at 09:59 , Luc Van Bogaert wrote:

> But this still leaves me with the question of how to reference my windowcontroller objects from the mainmenu nib? I need this because I want to modify the title of some menu items, depending on the state of the document windows. So I would like to make my windowcontroller objects menu delegates.

This isn't the ordinary way of getting this result.

The ordinary way is to implement 'validateUserInterfaceItem:' in each object in the action responder chain that is responsible for some of the menu items. In that method, the object checks to see if the item being "validated" is one of the ones it it responsible for (which may be different at different times, depending on the state of the document and/or the application). If so, it is free to do anything it wants to the item, including changing the title.

This decentralizes control over menu items (and other UI items handled through the same mechanism), which can make it hard to get a grasp on what items are handled where, but also makes decentralization of the interface via multiple nib files possible, which is the purpose you're trying to achieve.

> I thought about using an application delegate as file's owner in the mainmenu nib, and then target the menu items from this delegate. From the app delegate I can reference the window using keyWindow, but I haven't found a way to reference the windowcontroller objects...

Changing the main menu nib's Files Owner sounds like a terrible idea.

You're ignoring a fairly rich set of object interrelationships that eliminate the need to invent odd ways of referencing things. There is a singleton NSDocumentController that lists all the documents. Each document has a list of its window controller. Each window controller has a reference to its window. Windows have a "windowController" property. Window controllers have a "document" property. What is it that you think is missing?

That's beside the point, though, because if you handle the menu item validation the "ordinary way", you won't need to solve this unnecessary problem.


_______________________________________________

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

  • Follow-Ups:
    • Re: Document-based app: UI item validation
      • From: Luc Van Bogaert <email@hidden>
References: 
 >Document-based app: UI item validation (From: Luc Van Bogaert <email@hidden>)
 >Re: Document-based app: UI item validation (From: Jerry Krinock <email@hidden>)
 >Re: Document-based app: UI item validation (From: Luc Van Bogaert <email@hidden>)

  • Prev by Date: Re: Document-based app: UI item validation
  • Next by Date: Re: Document-based app: UI item validation
  • Previous by thread: Re: Document-based app: UI item validation
  • Next by thread: Re: Document-based app: UI item validation
  • Index(es):
    • Date
    • Thread