background color of NSTextView
background color of NSTextView
- Subject: background color of NSTextView
- From: email@hidden
- Date: Mon, 12 Feb 2007 17:42:15 +0100 (CET)
- Importance: Normal
Hello all,
I'm trying to produce a text view that displays a (variable) background
color on-screen
only, so that I cannot use the setBackgroundColor: method of NSTextView
directly. I had the following two ideas, which both failed (in both cases
the background color of the text view is still blank at run-time):
1) Create a subclass ColoredTextView of NSTextView :
@interface ColoredTextView : NSTextView {
NSColor* backgroundScreenColor;
}
-(void) setBackgroundScreenColor : (NSColor*) aColor;
@end
whose drawRect method is as follows :
- (void)drawRect:(NSRect)rect {
if ([[NSGraphicsContext currentContext] isDrawingToScreen]) {
[backgroundScreenColor set];
[NSBezierPath fillRect:rect];
}
[super drawRect:rect];
}
2) Create an auxiliary "unicolored" NSView whose frame is the same as the
text view.
What is the correct solution ?
Ewan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden