PDA

View Full Version : Menu Items and checkmarks




atczyme
Jul 13, 2009, 05:21 PM
I am converting an application to cocoa. I have a menu that has 25 items. Only one selection is valid at a time. I am having trouble with removing the checkmark from the current item (set in IB) and setting a new checkmark after user selection of that item.
I have a single IBOutlet for all the menu items. Based on the tag number, the program does its thing. So I know the item that was checked, as I have saved its tag. And I know the new item selected as it is sender. How can I recover the NSMenuItem for from the tag. this is what I tried, which does not work.
Any help would be appreciated.

- (IBAction)doSelectionMenu: (id)sender
{
int currentTag;
NSMenuItem *theMenuItem;

currentTag = active + 400;
theMenuItem = [NSMenuItem itemWithTag:currentTag];
[theMenuItem setState:NSOffState];

[sender setState:NSOnState];

}