Setting the color of NSCells within a NSMatrix
Setting the color of NSCells within a NSMatrix
- Subject: Setting the color of NSCells within a NSMatrix
- From: Roland Torres <email@hidden>
- Date: Mon, 8 Aug 2005 10:19:30 -0700
I'm trying to set the color of NSCells within an 8x8 NSMatrix, but am
having no luck.
I want to initialize each cell's color to successive shades of gray,
going from white to black, resulting in a palette of gray shades.
I've added code to do this, but the cells never change color.
I call a specific cell in the matrix from my controller object like
this:
GrayCell *aCell = [grayMatrix cellAtRow:x column:y]; //
my subclass of NSCell
NSColor *aColor = [NSColor grayColor]; //
example gray
NSRect cellFrame = [grayMatrix cellFrameAtRow:x column:y]; //
valid NSRect struct
[aCell drawColor:aColor inCellFrame:cellFrame]; //
invokes method shown below
[grayMatrix setNeedsDisplay:YES]; //
dunno if needed
In GrayCell, my -drawColor:inCellFrame: method gets invoked, and
looks like this:
- (void) drawColor:(NSColor *)aColor inCellFrame:(NSRect)cellFrame
{
[aColor set]; // is a valid NSColor object
NSRectFill( cellFrame ); // cellFrame has correct coords
}
But nothing happens. I've checked all the variables in the debugger,
and all have correct values and nothing is nil, but the color simply
never changes! (The color will change only if I manually click on a
cell in the matrix, and override NSCell's -drawWithFrame:inView:
method, which is an automatic callback, not a direct invocation.)
Roland
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden