Graphics artifacts in NSMatrix
Graphics artifacts in NSMatrix
- Subject: Graphics artifacts in NSMatrix
- From: Peter Ammon <email@hidden>
- Date: Thu, 8 Nov 2001 17:12:25 -0500
I am trying to implement an NSMatrix of my custom cells. To highlight
the cells, I do something like this in the cell class:
- (void)drawWithFrame:(NSRect)frame inView:(NSMatrix*)view {
BOOL isSelected=([[view selectedCells]
indexOfObjectIdenticalTo:self] != NSNotFound);
if (isSelected) {
//draw with highlights
}
else {
//draw without highlights
}
}
This works very well, except when I select a new cell in the matrix, it
doesn't redraw the old selected cell, so that the old selected cell
continues to appear highlighted until I scroll it offscreen and back on.
I've tried forcing it to redraw the old cell by overriding the
NSMatrix's mouseDown: method, and that works but still looks a little
weird: the old cell isn't unhilighted until after the new cell is
highlighted.
Can anyone suggest a way around this?
Also, how on earth does the NSMatrix keep track of the selected cells?
I've tried overriding selectCell: and selectCellAtRow: column:, but
neither get called when I click on a cell. Also, I can't see any ivars
in the NSMatrix that could store the selected cells (unless it's that
one opaque void*)
-Peter