Re: newb question on documents, nibs & the menu bar
Re: newb question on documents, nibs & the menu bar
- Subject: Re: newb question on documents, nibs & the menu bar
- From: PGM <email@hidden>
- Date: Sat, 28 Jan 2006 15:30:11 -0500
I use something like the following. I modified the code a bit in Mail,
so there is no guarantee that simply copy pasting will work, but you
may get the idea.
//connect this action to the popUpButton
//or include the code into your own popUpButton action
- (IBAction)clickedPopUpButton:(id)sender
{
int choice = [sender indexOfSelectedItem];
//get the menu to which the submenu belongs ("Action") and then the
submenu ("Choice")
NSMenu *choiceMenu = [[[[[NSApp mainMenu] itemWithTitle:@"Action"]
submenu] itemWithTitle:@"Choice"] submenu];
int i;
//loop through the available choices (three in your case) and tick
the correct one
for(i = 0; i < [choiceMenu numberOfItems]; i++){
if(i == choice){
[[choiceMenu itemWithTag:i] setState:NSOnState];
}
else{
[[choiceMenu itemWithTag:i] setState:NSOffState];
}
}
}
Best, Patrick
On 28 Jan, 2006, at 14:48, Mike Abdullah wrote:
I need some advice on getting the right behaviour in my app with
regard to the menu bar.
I have a doc-based app. In the document window there is a popup
button which offers the user 3 different choices. In my menu bar
there is a submenu that offers the equivalent of this, with a sperate
menu item for each item in the popup button.
I have used the First Responder in MainMenu.nib to send the events of
the user clicking on the menu bar item to the window's controller and
this works fine. However, how do I send stuff back? I need to place
a tick by whichever of the menu bar choices the user has made.
Thanks,
Mike.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden