Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUpButtonCell always select first item



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.