Exact Table Cell Value Double-Clicked (through Bindings)

Send Snippet To: Save this snippet to Code Collector Pro -- view all powidl's snippets
language: Objective-C
license: Other

Code for Snippet:

// For a table that's getting its values via Bindings, if you want on double-click to find the value of the exact cell
// that was double-clicked, this is one way.
-(void) awakeFromNib
	[dbTableView setTarget:self];
	[dbTableView setDoubleAction:@selector( doubleClickedTable: )];
-(void) doubleClickedTable:(id)sender
	if( ([sender clickedRow] > -1) && ([sender clickedColumn] > -1) )
		NSDictionary *rowDict = [[searchResultsArrayController arrangedObjects] objectAtIndex:[sender clickedRow]];
		NSDictionary *tableColumnValueBindingDict = [[[sender tableColumns] objectAtIndex:[sender clickedColumn]] infoForBinding:@"value"];
		NSArray *keyPathComponents = [[tableColumnValueBindingDict objectForKey:NSObservedKeyPathKey] componentsSeparatedByString:@"."];
		NSString *columnIdent = [keyPathComponents lastObject];
		NSString *dataDoubleClicked = [rowDict objectForKey:columnIdent];
		NSPasteboard *pb = [NSPasteboard generalPasteboard];
		[pb declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:self];
		[pb setString:dataDoubleClicked forType:NSStringPboardType];
comments powered by Disqus


Link to this snippet:

Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 798
Date Added: 2009-03-02 11:16:53
Last Modified: 0000-00-00 00:00:00

Web Analytics