I have an NSMenu attached to an NSSearchField as a searchMenuTemplate.

The menu is as Follows:

-------
All
Start
End
Country
Station
Notes
Frequency
--------

If the user selects "All", I want to remove all check marks from other
selected menu items. If the user selects anything except "All", then I
want to remove the check from the All menu item. In order to allow
this, I have outlets set for each menu item so I can change its state:

----------
        IBOutlet NSMenuItem *allMenuItem;
        IBOutlet NSMenuItem *startMenuItem;
        IBOutlet NSMenuItem *endMenuItem;
        IBOutlet NSMenuItem *countryMenuItem;
        IBOutlet NSMenuItem *stationMenuItem;
        IBOutlet NSMenuItem *notesMenuItem;
        IBOutlet NSMenuItem *frequenciesMenuItem;
----------

This seems like it would be easy to implement, but I cant seem to set
the state on a menu item via the IBOutlet reference (and I have triple
checked that the outlets are set correctly, and the debugger seems to
confirm this). I can only set the state in response to the action of
the item being clicked.

------------
-(IBAction)handleSearchMenuItems:(NSMenuItem *)menuItem
{
        NSLog(@"Search");

        NSInteger state = [menuItem state];
        
        if(state == NSOffState)
        {
                [menuItem setState:NSOnState];
                [allMenuItem setState:NSOffState];
        }
        else
        {
                [menuItem setState:NSOffState];
        }
}

-(IBAction)handleSearchAllItems:(NSMenuItem *)allMenuItemSender
{
        NSInteger state = [allMenuItemSender state];

        if(state == NSOffState)
        {
                [allMenuItemSender setState:NSOnState];
                
                [startMenuItem setState:NSOffState];
                [endMenuItem setState:NSOffState];
                [countryMenuItem setState:NSOffState];
                [stationMenuItem setState:NSOffState];
                [notesMenuItem setState:NSOffState];
                [frequenciesMenuItem setState:NSOffState];      
        }
        else
        {
                [allMenuItemSender setState:NSOffState];
        }
}
------------

So, in the code above, I can set the state for allMenuItemSender and
menuItem, but not for the NSMenuItems which were not clicked.

Again, this seems like it should be simple, but I am completely
stumped (I am pretty new to Cocoa).

Does anyone have any idea of what might be going on?

mike
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to