NSTextView subclass redrawing weirdness
NSTextView subclass redrawing weirdness
- Subject: NSTextView subclass redrawing weirdness
- From: "John Cassington" <email@hidden>
- Date: Sun, 9 Jul 2006 11:07:13 +1000
Hi everyone,
I have created a subclass of on NSTextView so that I can add a 1 pixel
border around the edge of it. This is working, but it seems to be getting
darker every time i do something that causes a redraw (such as hitting
enter).
For example, I type a line of text during which the border remains normal,
but when i hit enter the area of the border which lines up with the previous
line goes one shade darker.
The only reason i can think for this happening is that i am not using
NSView's drawing methods properly.
Here is my code:
<< BEGIN CODE >>
- (id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil) {
[self setBackgroundColor:[NSColor whiteColor]];
[self setAllowsUndo:YES];
[self setVerticallyResizable:NO];
}
return self;
}
-(void)drawRect:(NSRect)rect {
NSRect wholeRect = [self bounds];
NSRect textRect = NSMakeRect(wholeRect.origin.x+1,wholeRect.origin.y+1,
wholeRect.size.width-2,wholeRect.size.height-2);
[[NSColor blackColor] set];
[NSBezierPath setDefaultLineWidth:1];
[NSBezierPath strokeRect:wholeRect];
[super drawRect:textRect];
}
<< END CODE >>
I hope that somebody will be able to help me, because i am not too sure
about on screen drawing.
Thanks,
John Cassington
_______________________________________________
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