• 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: Luc Van Bogaert <email@hidden>
  • Date: Sun, 21 Aug 2011 22:53:10 +0200

On 21 Aug 2011, at 21:57, Quincey Morris wrote:

> On Aug 21, 2011, at 12:22 , Luc Van Bogaert wrote:
>
>> 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".
>
> OK, gotcha.
>
>> 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 ?
>

> My solution was to assign the menu item (the one with the submenu) a dummy action that does nothing. Then I used the normal 'validateUserInterfaceItem:' mechanism to enable or disable the menu item with that action, based on whether all of the submenu items were enabled or not. You could use a similar approach to change the menu title instead of its enable status. It's certainly possible that there's some obscure, unwanted UI behavioral side-effect of doing this, but I haven't seen any.

I've been trying to do this during the last half hour, but without success so far... I'll give it one more go tomorrow.

>
> For completeness, I'll add that if there's some genuine reason why you couldn't use the 'validateUserInterfaceItem:' mechanism to solve your problem, then the correct solution may well be to use a menu delegate after all. But in that case, I wouldn't use the window controller as the delegate, I'd use a global (singleton) object such as the app delegate instead. That would move you're app's knowledge of the menu structure (which is app-global knowledge more than document-specific knowledge) into an app-global place, and it would properly separate the menu-structuring behavior from the menu-validating behavior.

Using the app-delegate is what I've implemented at this moment, and this works just fine. If the other solution (see above) doesn't work, this is what I'll stick to.

>
> But unless you're forced into this more invasive approach, I'd suggest you try the dummy action solution.
>


Thanks (again) for your help.


_______________________________________________

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: [SOLVED] 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>)
 >Re: Document-based app: UI item validation (From: Quincey Morris <email@hidden>)
 >Re: Document-based app: UI item validation (From: Luc Van Bogaert <email@hidden>)
 >Re: Document-based app: UI item validation (From: Quincey Morris <email@hidden>)
 >Re: Document-based app: UI item validation (From: Luc Van Bogaert <email@hidden>)
 >Re: Document-based app: UI item validation (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Can Peer-to-Peer Model Be Launched in AppStore?
  • Next by Date: Re: [SOLVED] Document-based app: UI item validation
  • Previous by thread: Re: Document-based app: UI item validation
  • Next by thread: Re: [SOLVED] Document-based app: UI item validation
  • Index(es):
    • Date
    • Thread