Subclassing a NSTextView
Subclassing a NSTextView
- Subject: Subclassing a NSTextView
- From: Anthony Duer <email@hidden>
- Date: Thu, 30 Jan 2003 22:55:58 -0800
I'm trying to create a subclass of NSTextView because I need to foward
the keyDown: events to another NSTextView, which works fine when I
override keyDown:. However, I also need to set up the background and
foreground color of the subclassed NSTextView. The problem comes when I
call [self setTextColor: [NSColor whiteColor]];. Without that call, the
NSTextView sets up normally, except the text is black on black, hence
unreadable. If I call to set the foreground color, suddenly my
subclassed NSTextView thinks it should be about one-sixth its normal
size.
Not only that, once text starts being inserted via the insertText:
method, the color comes out fine (white on black) but the NSTextView
starts misplacing where the text should be (It starts at the bottom),
but it also starts growing vertically downward passing where it should
normally stop until it consumes the entire NSWindow is resides in. (It
also consumed a NSSplitView. The only other odd thing I notice is that
the vertical scroll bar doesn't appear no matter how much text gets
pumped into the NSTextView.
Any help? I'm not sure why setTextColor: is causing such a problem.
For the record:
#import "mainView.h"
@implementation mainView
-(void)keyDown: (NSEvent *)e
{
[[self window] makeFirstResponder: [self delegate]];
[[self delegate] keyDown: e];
}
-(void)awakeFromNib
{
[self setEditable: NO];
[self setBackgroundColor: [NSColor blackColor]];
[self setTextColor: [NSColor whiteColor]]; //Causes the problem,
even if I call [mainView setTextColor from another class.
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.