• 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: Dealing with NSPopupButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dealing with NSPopupButton


  • Subject: Re: Dealing with NSPopupButton
  • From: j o a r <email@hidden>
  • Date: Sat, 23 Feb 2002 14:21:35 +0100

On Saturday, February 23, 2002, at 01:03 , Pete Yandell wrote:

if ([[myPopUp titleOfSelectedItem] isEqualToString:@"Letter"]) {

...if you ever plan to release a localized version of your application, it's probably not a good idea to build the menu in code and later match on the string returned...

My suggestion: Build the pop-up button in IB and set a tag for each menu item (the tag can be set in IB). Then, when the action is called, check the tag returned instead of the title of the item. Something like this:

- (IBAction)menuChanged:(id)sender
{
int tag = [[sender selectedItem] tag];

switch (tag) {
case 0 :
// handle the item with tag 0
break;
case 1 :
// etc.
break;
}
}

If you'd later fancy to release a localized version, simply provide a localized NIB where the tags for the corresponding items are the same.

j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Dealing with NSPopupButton
      • From: Nicholas Shanks <email@hidden>
References: 
 >Re: Dealing with NSPopupButton (From: Pete Yandell <email@hidden>)

  • Prev by Date: Re: Dealing with NSPopupButton
  • Next by Date: Re: Dealing with NSPopupButton
  • Previous by thread: Re: Dealing with NSPopupButton
  • Next by thread: Re: Dealing with NSPopupButton
  • Index(es):
    • Date
    • Thread