• 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
NSTableView/NSPopUpButtonCell Mysteries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView/NSPopUpButtonCell Mysteries


  • Subject: NSTableView/NSPopUpButtonCell Mysteries
  • From: Daniel Todd Currie <email@hidden>
  • Date: Mon, 16 Feb 2004 00:46:02 -0800

Here's an odd problem and my hypothesis as to the cause:

I have two NSLogs at a place in my source where I am updating the menu for an NSPopUpButtonCell:

NSLog(@"table data: %i", [[[targetTable tableColumnWithIdentifier:@"archive"] dataCellForRow:[targetTable selectedRow]] indexOfSelectedItem]);

NSLog(@"targets data: %i", [[[targets objectAtIndex:[targetTable selectedRow]] objectForKey:@"archive"] intValue]);

The tableView:setObjectValue:forTableColumn:row: method for targetTable edits the data source, targets, as follows:

- (void)tableView:(NSTableView *)aTableView setObjectValue:anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
...

if([[aTableColumn identifier] isEqualToString:@"archive"])
{
NSLog(@"setting targets data: %i %@", [[aTableColumn dataCell] indexOfSelectedItem], [aTableColumn identifier]);

[[targets objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:[[aTableColumn dataCell] indexOfSelectedItem]] forKey:[aTableColumn identifier]];
}
}

Here's my run log:

2004-02-16 00:12:15.857 Archive It[1227] setting targets data: 2 archive
2004-02-16 00:12:17.130 Archive It[1227] table data: 0
2004-02-16 00:12:17.130 Archive It[1227] targets data: 2

The NSLogs for the table data and targets data occur while the window containing the table view is in the background, i.e. the table selection is gray/inactive. Perhaps this is causing me to get 0 for the indexOfSelectedItem of my NSPopUpButtonCell? When I test this hypothesis with an NSLog while the table is first responder, I get the correct result:

2004-02-16 00:37:13.705 Archive It[1244] table data: 2

Is this perhaps a bug in the Cocoa API or am I overlooking something? It seems to me that the indexOfSelectedItem method should return the correct value, regardless of the table's responder status. Maybe that's just me though...

Thanks in advance for your response.

-- Daniel Currie
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSTableView/NSPopUpButtonCell Mysteries
      • From: Stephane Sudre <email@hidden>
  • Prev by Date: Re: How do I soft-wrap text at a specific line length?
  • Next by Date: Re: NSImage and flipping
  • Previous by thread: Re: ScalingScrollView with Sketch [workaround]
  • Next by thread: Re: NSTableView/NSPopUpButtonCell Mysteries
  • Index(es):
    • Date
    • Thread