• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: newb question on documents, nibs & the menu bar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: newb question on documents, nibs & the menu bar
      • From: PGM <email@hidden>
References: 
 >newb question on documents, nibs & the menu bar (From: Mike Abdullah <email@hidden>)
 >Re: newb question on documents, nibs & the menu bar (From: PGM <email@hidden>)

  • Prev by Date: Re: threads or processes?
  • Next by Date: Finder integration or plug-in
  • Previous by thread: Re: newb question on documents, nibs & the menu bar
  • Next by thread: Re: newb question on documents, nibs & the menu bar
  • Index(es):
    • Date
    • Thread