NSMenuItem enabling
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