• 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: Custom NSMenuItems on the fly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSMenuItems on the fly?


  • Subject: Re: Custom NSMenuItems on the fly?
  • From: Alastair Houghton <email@hidden>
  • Date: Fri, 6 Jul 2007 00:36:50 +0100

On 5 Jul 2007, at 21:23, Gregory Weston wrote:

I'd like to use menu:updateItem:atIndex:shouldContinue: to build a volatile menu on the fly (Yes, I know, changing menus are generally bad. In this case it's appropriate.), but I'd also like to use a custom subclass of NSMenuItem for the actual items. This _seems_ to work fine if within my method I remove the provided item from the menu and insert a new one at the same index. The problem I run into is that even though I set the target and action for that newly- created menu item, it the target never gets the opportunity to validate the menu item (and as a result those items are permanently disabled). The validation method _is_ invoked for one menu item that I don't try to replace.

Is there a better way to specify the class of the items I want, or is there a way to ensure validation happens?

It's probably a stupid question, but since such things often elicit solutions to problems, you did tell the NSMenu to - setAutoenablesItems:YES, right?


Also, have you tried calling -update on your NSMenu to see what happens? For normal application menus, this gets called by the framework automatically, but if this menu is being used in an unusual way, perhaps it isn't being called for some reason?

Kind regards,

Alastair.

--
http://alastairs-place.net




_______________________________________________

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: Custom NSMenuItems on the fly?
      • From: Gregory Weston <email@hidden>
References: 
 >Custom NSMenuItems on the fly? (From: Gregory Weston <email@hidden>)

  • Prev by Date: Deleting a Core Data stack directory
  • Next by Date: Re: Deleting a Core Data stack directory
  • Previous by thread: Re: Custom NSMenuItems on the fly?
  • Next by thread: Re: Custom NSMenuItems on the fly?
  • Index(es):
    • Date
    • Thread