• 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
[SOLVED] Re: NSPopUpButtonCell in subclass of NSCell - Selection not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: NSPopUpButtonCell in subclass of NSCell - Selection not working


  • Subject: [SOLVED] Re: NSPopUpButtonCell in subclass of NSCell - Selection not working
  • From: Michael Becker <email@hidden>
  • Date: Mon, 8 Nov 2004 15:05:08 +0100

I solved the issue and want to share the solution, I think this might be of interest to some people. Here is the URL to the example that helped me:
http://developer.apple.com/samplecode/Sample_Code/Cocoa/ Clock_Control.htm


Am 08.11.2004 um 14:16 schrieb Michael Becker:
Okay, it seems like I am finally almost done with this, there's only one major flaw. I have a tableview displaying custom cells in one column. The custom cells hold an NSImage and an NSPopUpButton. Now here's my problem: I cannot get the NSPopUpButton to work properly.

The key was to override -setObjectValue: and -objectValue in the subclass of NSCell. I made my cell accept custom classes like this:


- (void)setObjectValue:(NSObject *)anObject {
if ([ anObject isKindOfClass:[ PCProduct class]]) {
// Configure the cell's NSPopUpButton
// 'anObject' holds all the necessary information (selected item, etc.)
}
}


- (id)objectValue {
	return popUpButton;
}

Now I can simply use the good old NSTableViewDataSource methods like this:

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
if ([[ aTableColumn identifier] isEqualTo:@"product"]) {
return [ shoppingCart itemAtIndex:rowIndex];
}
return nil;
}


- (void)tableView:(NSTableView *)tv setObjectValue:(id)objectValue forTableColumn:(NSTableColumn *)tc row:(int)row {
if ([[tc identifier] isEqualToString:@"product"]) {
[[shoppingCart itemAtIndex:row] selectVariantAtIndex:[ objectValue indexOfSelectedItem]];
}
}


Cheers,
Michael

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSPopUpButtonCell in subclass of NSCell - Selection not working (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: $10 for a few [hours?] work
  • Next by Date: Re: $10 for a few [hours?] work
  • Previous by thread: NSPopUpButtonCell in subclass of NSCell - Selection not working
  • Next by thread: Re: NSPopUpButtonCell in subclass of NSCell - Selection not working
  • Index(es):
    • Date
    • Thread