• 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
NSPopUpButtonCell always select first item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUpButtonCell always select first item


  • Subject: NSPopUpButtonCell always select first item
  • From: Ivan C Myrvold <email@hidden>
  • Date: Thu, 31 Jan 2008 12:30:36 +0100

I have made the following delegate method below in my window controller, by setting a category in NSTableColumn.
This works fine, showing a popup button in one of the columns of my NSOutlineView. I just chose row 5 for simplicity of testing this out.
I can click the popup button in row 5, and it shows the two menu items "number one" and "number two" as it should.
But my problem is that even if I choose "number two" menu item, or other menu item if I have more, it always snaps back to "number one".


I am baffled by this, and have not been able to find out why this happens.
I of course wants the menu item I selects to be shown after I have selected it.


Ivan

- (id)tableColumn:(NSTableColumn *)column inOutlineView:(NSOutlineView *)outlineView dataCellForRow:(int)row {
if (row == 5) {
NSPopUpButton *mybutton = [popUpButtonDict objectForKey:[NSNumber numberWithInt:row]];

if (!mybutton) {
mybutton = [opopUpButtonCell copy]; //opopUpButtonCell is an outlet to an NSPopUpButtonCell in IB
[mybutton removeAllItems];
[mybutton addItemWithTitle:@"number one"];
[mybutton addItemWithTitle:@"number two"];
[popUpButtonDict setObject:mybutton forKey:[NSNumber numberWithInt:row]];
[opopUpButtonCell release];
}
return mybutton;
} else
return otextFieldCell; //otextFieldCell is an outlet to an NSTextFieldCell in IB
}
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPopUpButtonCell always select first item
      • From: Benjamin Stiglitz <email@hidden>
  • Prev by Date: Re: CoreData and NSOperation
  • Next by Date: Re: killing background processes with UNIX in cocoa?
  • Previous by thread: Re: Login item support for Panther, Tiger and Leopard
  • Next by thread: Re: NSPopUpButtonCell always select first item
  • Index(es):
    • Date
    • Thread