Hi all,
I am implementing my own subclass of NSTableView which has a gradient selection marker like iTunes or iMovie.
I have got all my subclasses set up and I have prepared the image for the selection marker, but I have hit a maddening brick wall.
I am using the following code to draw my custom selection in my NSTableView subclass.
When I load some data into my table view and click on the first item my selection is drawn perfectly.
However, when I click on any of the other items nothing happens apart from a slight change of the color of the text. I can only seem to draw the selection on the first item.
I have tried absolutely everything and I cannot get past this stumbling block.
Has anyone else experienced this or have any idea what I have missed?
Regards,
Chris
I am implementing my own subclass of NSTableView which has a gradient selection marker like iTunes or iMovie.
I have got all my subclasses set up and I have prepared the image for the selection marker, but I have hit a maddening brick wall.
I am using the following code to draw my custom selection in my NSTableView subclass.
Code:
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
if ([self selectedRow] == -1) return;
if (__useDarkProLook)
{
[self lockFocus];
NSImage *selImage = [NSImage imageNamed:@"TableViewSelection.tiff"];
[selImage setFlipped:[self isFlipped]];
NSIndexSet *selectedRowIndexes = [self selectedRowIndexes];
NSInteger currentIndex = [selectedRowIndexes firstIndex];
while (currentIndex != NSNotFound)
{
NSRect rowRect = [self rectOfRow:currentIndex];
if (!NSIsEmptyRect(rowRect))
{
NSLog(@"Drawing selection for %llu (%f, %f, %f, %f)", currentIndex, rowRect.origin.x, rowRect.origin.y, rowRect.size.width, rowRect.size.height);
[selImage drawInRect:rowRect fromRect:rowRect operation:NSCompositeSourceOver fraction:1.0];
}
currentIndex = [selectedRowIndexes indexGreaterThanIndex:currentIndex];
}
[self unlockFocus];
}
[super highlightSelectionInClipRect:clipRect];
}
- (id)_highlightColorForCell:(NSCell *)cell;
{
if (__useDarkProLook) return nil;
return [super _highlightColorForCell:cell];
}
However, when I click on any of the other items nothing happens apart from a slight change of the color of the text. I can only seem to draw the selection on the first item.
I have tried absolutely everything and I cannot get past this stumbling block.
Has anyone else experienced this or have any idea what I have missed?
Regards,
Chris