• 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
NSMenuItem enabling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMenuItem enabling


  • Subject: NSMenuItem enabling
  • From: Andreas Höschler <email@hidden>
  • Date: Thu, 14 Oct 2010 18:13:59 +0200

Hi all,

I am still having difficulties getting the NSMenuItems of a programmatically built menu enabled. I am doing

_sdmMenu = [[NSMenu alloc] initWithTitle:@"SDM"];
[_sdmMenu addItemWithTitle:@"Emphasize" action:@selector(emphasize:) keyEquivalent:@"e"];
[_sdmMenu addItemWithTitle:@"Formula" action:@selector(createFormula:) keyEquivalent:@"y"];
...
[_sdmMenu addItemWithTitle:@"Print" action:@selector(printLaTeX) keyEquivalent:@"p"];
}
NSMenuItem *anchorItem = [[NSApp mainMenu] itemWithTitle:@"SDM"];
if (!anchorItem)
{
anchorItem = [[NSApp mainMenu] addItemWithTitle:@"SDM" action:@selector(doNothing:) keyEquivalent:@""];
[[NSApp mainMenu] setSubmenu:_sdmMenu forItem:anchorItem];
}
[_sdmMenu update];
[_sdmMenu setAutoenablesItems:YES];


I open a window with a scrollView with a NSTextView sublcass as the documentView. The NSTextView subclass implements

-emphasize:
-createFormula:
...

The validateMenuItem: method is not implemented or always returns YES: The delegate of the window is my document controller class. This really should work and it does on MacOSX 10.2, but on MacOSX 10.5 the menu items are all greyed out. What am I doing wrong?

Thanks a lot!

Regards,

 Andreas

_______________________________________________

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: NSMenuItem enabling
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Why is 'missing sentinel in function call' appearing?
  • Next by Date: Debug Problem on MacOSX 10.5
  • Previous by thread: NSMenuItem enabling
  • Next by thread: Re: NSMenuItem enabling
  • Index(es):
    • Date
    • Thread