diff options
-rw-r--r-- | Source/SPTableContentDelegate.m | 20 | ||||
-rw-r--r-- | Source/SPTextAndLinkCell.h | 3 | ||||
-rw-r--r-- | Source/SPTextAndLinkCell.m | 9 |
3 files changed, 25 insertions, 7 deletions
diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m index 8f228aa0..53f65468 100644 --- a/Source/SPTableContentDelegate.m +++ b/Source/SPTableContentDelegate.m @@ -48,6 +48,7 @@ #import "SPTableData.h" #import "SPFieldEditorController.h" #import "SPThreadAdditions.h" +#import "SPTextAndLinkCell.h" #import <pthread.h> #import <SPMySQL/SPMySQL.h> @@ -464,7 +465,8 @@ if (![cell respondsToSelector:@selector(setTextColor:)]) return; - BOOL showCellAsGray = NO; + BOOL cellIsNullOrUnloaded = NO; + BOOL cellIsLinkCell = [cell isMemberOfClass:[SPTextAndLinkCell class]]; NSUInteger columnIndex = [[tableColumn identifier] integerValue]; // If user wants to edit 'cell' set text color to black and return to avoid @@ -473,6 +475,7 @@ && [tableView editedRow] == rowIndex && (NSUInteger)[[NSArrayObjectAtIndex([tableView tableColumns], [tableView editedColumn]) identifier] integerValue] == columnIndex) { [cell setTextColor:blackColor]; + if (cellIsLinkCell) [cell setLinkActive:NO]; return; } @@ -483,22 +486,31 @@ pthread_mutex_lock(&tableValuesLock); if (rowIndex < (NSInteger)tableRowsCount && columnIndex < [tableValues columnCount]) { - showCellAsGray = [tableValues cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex]; + cellIsNullOrUnloaded = [tableValues cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex]; } pthread_mutex_unlock(&tableValuesLock); } else { - showCellAsGray = [tableValues cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex]; + cellIsNullOrUnloaded = [tableValues cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex]; } - if (showCellAsGray) { + if (cellIsNullOrUnloaded) { [cell setTextColor:lightGrayColor]; } else { [cell setTextColor:blackColor]; } + + // Disable link arrows for the currently editing row and for any NULL or unloaded cells + if (cellIsLinkCell) { + if (cellIsNullOrUnloaded || [tableView editedRow] == rowIndex) { + [cell setLinkActive:NO]; + } else { + [cell setLinkActive:YES]; + } + } } } diff --git a/Source/SPTextAndLinkCell.h b/Source/SPTextAndLinkCell.h index 73eeb486..74f28cc8 100644 --- a/Source/SPTextAndLinkCell.h +++ b/Source/SPTextAndLinkCell.h @@ -33,6 +33,7 @@ @interface SPTextAndLinkCell : NSTextFieldCell { BOOL hasLink; + BOOL linkActive; NSButtonCell *linkButton; id linkTarget; @@ -43,6 +44,8 @@ NSInteger drawState; } +@property (readwrite, assign) BOOL linkActive; + - (void) setTarget:(id)theTarget action:(SEL)theAction; - (NSInteger) getClickedColumn; - (NSInteger) getClickedRow; diff --git a/Source/SPTextAndLinkCell.m b/Source/SPTextAndLinkCell.m index 249c5261..3e91914a 100644 --- a/Source/SPTextAndLinkCell.m +++ b/Source/SPTextAndLinkCell.m @@ -34,6 +34,8 @@ @implementation SPTextAndLinkCell +@synthesize linkActive; + /** * Provide a method to derive the link rect from a cell rect. */ @@ -53,6 +55,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) self = [super initWithCoder:coder]; if (self) { hasLink = NO; + linkActive = YES; linkButton = nil; linkTarget = nil; drawState = SPLinkDrawStateNormal; @@ -131,7 +134,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) { // Fast case for no arrow - if (!hasLink) { + if (!hasLink || !linkActive) { [super drawInteriorWithFrame:aRect inView:controlView]; return; } @@ -179,7 +182,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) { // Fast case for no link - make entire cell editable click area - if (!hasLink) return NSCellHitContentArea | NSCellHitEditableTextArea; + if (!hasLink || !linkActive) return NSCellHitContentArea | NSCellHitEditableTextArea; NSPoint p = [[[NSApp mainWindow] contentView] convertPoint:[event locationInWindow] toView:controlView]; NSRect linkRect = SPTextLinkRectFromCellRect(cellFrame); @@ -204,7 +207,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect) { // Fast case for no link - if (!hasLink) return [super trackMouse:theEvent inRect:cellFrame ofView:controlView untilMouseUp:untilMouseUp]; + if (!hasLink || !linkActive) return [super trackMouse:theEvent inRect:cellFrame ofView:controlView untilMouseUp:untilMouseUp]; NSPoint p = [controlView convertPoint:[theEvent locationInWindow] fromView:nil]; NSRect linkRect = SPTextLinkRectFromCellRect(cellFrame); |