Re: Dealing with NSPopupButton
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.