From 2583d511db232ca276c1718fbef871880c00625b Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 19 Feb 2010 17:12:49 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20color=20setting=20for=20editing=20a?= =?UTF-8?q?=20table=20cell=20which=20is=20set=20to=20NULL=20if=20table=20c?= =?UTF-8?q?olumns=20are=20reordered=20by=20the=20user=20=E2=80=A2=20initia?= =?UTF-8?q?l=20transition=20to=20insert=20via=20-=20up=20to=20now=20-=20^?= =?UTF-8?q?=E2=87=A7N=20a=20[NSNull=20null]=20object=20into=20the=20table'?= =?UTF-8?q?s=20data=20source=20directly=20without=20parsing=20a=20possible?= =?UTF-8?q?=20@"NULL"=20string=20-=20it's=20a=20first=20test=20-=20and=20w?= =?UTF-8?q?orks=20only=20for=20CMCopyTable=20subclassed=20tables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTextViewAdditions.m | 9 +++++++++ Source/TableContent.m | 15 ++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'Source') diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m index 63a01798..ef0dff38 100644 --- a/Source/SPTextViewAdditions.m +++ b/Source/SPTextViewAdditions.m @@ -390,6 +390,15 @@ */ - (IBAction)insertNULLvalue:(id)sender { + + // If self is an edited table cell insert [NSNull null] directly in the table's data source + // TODO: up to now only for CMCopyTable + if([[[[self delegate] class] description] isEqualToString:@"CMCopyTable"]) { + id aTableView = [self delegate]; + NSUInteger currentEditedColumn = [aTableView editedColumn]; + NSUInteger currentEditedRow = [aTableView editedRow]; + [[aTableView delegate] tableView:aTableView setObjectValue:[NSNull null] forTableColumn:[[aTableView tableColumns] objectAtIndex:currentEditedColumn] row:currentEditedRow]; + } id prefs = [NSUserDefaults standardUserDefaults]; if([self respondsToSelector:@selector(insertText:)]) if([prefs objectForKey:SPNullValue] && [[prefs objectForKey:SPNullValue] length]) diff --git a/Source/TableContent.m b/Source/TableContent.m index 3b22db96..4d878527 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -2718,7 +2718,9 @@ // If user wants to edit 'cell' set text color to black and return to avoid // writing in gray if value was NULL - if ( [aTableView editedColumn] == columnIndex && [aTableView editedRow] == rowIndex) { + if ([aTableView editedColumn] != -1 + && [aTableView editedRow] == rowIndex + && [[NSArrayObjectAtIndex([aTableView tableColumns], [aTableView editedColumn]) identifier] integerValue] == columnIndex) { [cell setTextColor:[NSColor blackColor]]; return; } @@ -2744,17 +2746,12 @@ } NSDictionary *column = NSArrayObjectAtIndex(dataColumns, [[aTableColumn identifier] integerValue]); - - if (anObject) { - - // Restore NULLs if necessary - if ([anObject isEqualToString:[prefs objectForKey:SPNullValue]] && [[column objectForKey:@"null"] boolValue]) - anObject = [NSNull null]; + if (anObject) [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:anObject]; - } else { + else [tableValues replaceObjectInRow:rowIndex column:[[aTableColumn identifier] integerValue] withObject:@""]; - } + } #pragma mark - -- cgit v1.2.3