How to force Matrix to draw updated cells?
How to force Matrix to draw updated cells?
- Subject: How to force Matrix to draw updated cells?
- From: Youngjin Kim <email@hidden>
- Date: Fri, 22 Jun 2001 19:32:17 +0900
I have a set of buttonCells in a panel which are to be drawn by drawing
selector via customImageRep. These cells are enclosed in a matrix
view. Since button's image has to be changed in runtime, I put a
flag(states) in my subclassed MyCustomImageRep, then refered to it to
draw proper image according to states.
// drawing selector for NSCustomImageRep
-(IBAction)drawMyButtonImage:(NSCustomImageRep *)rep{
int states = [(MyCustomImageRep*)rep states];
switch (states) { // draw different button image
according to states.
case 0:
...
case 1:
...
}
}
// this supposed to draw updated cells but not working.
- (IBAction)updateSelectedCell:(id)sender {
NSImage *image = [[matrix selectedCell] image];
MyCustomImageRep *rep = (MyCustomImageRep*)[[image representations]
objectAtIndex:0];
[rep setStates:1]; // change states.
[matrix setNeedsDisplay:YES]; // this doesn't call draw
selector. it just draws old image of cells.
}
The problem is when I send setNeedsDisplay to the matrix, the matrix
doesn't draw updated buttons. It draws old image of cells.
Shortly speaking, I get unchanged image of matrix even its cells are
changed. How do I force a matrix to draw its cells according to cell's
image representation?
Youngjin