setDoubleAction with Editable Cells in Leopard

If you set an NSTableView’s double action in Tiger or earlier by something like:

	[tasksTable setTarget:self];
	[myTable setDoubleAction:@selector(doDoubleClick:)];

doDoubleClick would only get fired for clicks on blank cells, headers, or uneditable cells. The documentation still reflects this. In Leopard, this is no longer the case: doDoubleClick gets called no matter what. If you want the old behavoir - that is, if you want the cells to receive the edit action, you must do it manually. Clickedrow is -1 for headers and empty cells. Thus, the code would look something like:

- (IBAction)doDoubleClick:(id)sender {
	if([sender clickedRow] == -1){
		//your special action goes here
	}
	else {
		[myTable editColumn:[sender clickedColumn]
				row:[sender clickedRow]
				withEvent:nil select:YES];
	}
}

Hope this helps somebody scratching their head with the same issue!

Leave a Reply