the problem is i'm stuck with a very large legacy code base that i must modify minimally to shoehorn into Cocoa. this same code must cross compile on windows, so i can't change the underlying architecture, which has for a decade now relied on the fact that we can share submenus across many super-menus.

what seems to work at the moment is doing this:

[subMenu setSupermenu:NULL];

just before setting it AGAIN as a sub menu to another super menu.

i am quite sure i'll need to do some shenanegans to avoid over- releasing when we dispose our menus, but for now it seems to be working.

does anyone feel the universe will explode in my face by doing this?

On Aug 6, 2009, at 11:28 AM, Jerry Krinock wrote:


On 2009 Aug 05, at 22:08, Graham Cox wrote:


On 06/08/2009, at 5:41 AM, David M. Cotter wrote:

in carbon, you can have a sub menu that is used in more than one super menu.

is there a trick to get this to go in Cocoa?

As far as I know a menu has to be a distinct instance - you can't share them. I think I tried it once and it failed miserably.

I've never tried that, but one thing that would work is to generate the menu on the fly when it's needed. You can use the same method to generate each submenu. For example, I have a contextual menu item which contains two items "Copy To ->" and "Move To ->". The method you'll want to use is -menuNeedsUpdate. The stated purpose of this method is for lazy generation of hierarchical menus, but it should work for David's purpose also.

_______________________________________________

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