Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: NSPopUpButt...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 3721 of 3882
Post > Topic >>

Re: NSPopUpButton

by jim@[EMAIL PROTECTED] (jim) Apr 26, 2008 at 09:12 AM

<joe.garifo@[EMAIL PROTECTED]
> wrote:

> I'm trying to teach myself objective C and was working on the tutorial
> from Apple on Cocoa. I tried to add a NSPopUpButton using IB to list
> different currencies to choose from. My first issue is that when it
> first starts up it lists the default 3 items, but once you hit the
> button it lists mine. My second is that once it gets to that, it only
> uses the rate of the first item on the list. Any help would be lovely.

As a suggestion:

In Interface Builder doubleclick your popupbutton and delete all three
entries (the items marked 'Item 1', 'Item 2' and 'Item 3'). Save.

In your object have a section like this:

-(void)awakeFromNib
{
        [currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to UK Pounds"];
        [currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to Euros"];
        [currencyButton addItemWithTitle:@[EMAIL PROTECTED]
"Dollars to Credits"];
}

where 'currencyButton' is an IBOutlet pointing at your popupButton.

Then, assuming your popupButton is also pointing at an IBAction you can
read the selected option like this:

-(IBAction)buttonPressed:(id)sender
{
        int convertOption = [sender indexOfSelectedItem];
....
}

convertOption will be 0 for the first item, 1 for the second etc.

Jim
-- 
"Well, well. We've come a long way from the Prime Minister's
 exploding cake." - Adam West, Batman. 

Find me at http://www.UrsaMinorBeta.co.uk
 




 3 Posts in Topic:
NSPopUpButton
joe.garifo@[EMAIL PROTECT  2008-04-25 13:51:57 
Re: NSPopUpButton
David Phillip Oster <o  2008-04-25 20:09:11 
Re: NSPopUpButton
jim@[EMAIL PROTECTED] (j  2008-04-26 09:12:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 1:30:44 CST 2008.