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: Mike Abdullah <email@hidden>
- Date: Sat, 28 Jan 2006 21:09:52 +0000
OK, I can see how that code would work. But the thing is, say I
switch to a different document within the app which has a different
setting, then surely this wouldn't work? As far as I can see, I
would have to detect the document switch somehow and set the menu bar
manually from this.
It just seems to me that this is not a very Cocoa way of doing
things, that's all.
Mike.
On 28 Jan 2006, at 20:30, PGM wrote:
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