Struggling with NSTextView in a custom view
Struggling with NSTextView in a custom view
- Subject: Struggling with NSTextView in a custom view
- From: Koen van der Drift <email@hidden>
- Date: Sat, 25 Jan 2003 11:24:27 -0500
Hi,
I am struggling to get an NSTextView into a custom view, and would
appreciate any help. Basically what I want is a view which has two
textviews, each with their own text container and layoutmanager, but which
share the textstorage.
So, based on chapter 12 in Hillegass' book, I created a customview. If I
use his code in drawRect, it just works fine, so I assume the view is set
up correctly.
Now I would like to add an NSTextView to it, and I am following the Cocoa
docs from Apple, 'Creating an NSTextView programmatically'. In the custom
view's initWithFrame, I do the following:
- (id)initWithFrame:(NSRect)frameRect
{
if ( [super initWithFrame:frameRect] )
{
NSWindow *aWindow = [self window];
NSRect cFrame = [[aWindow contentView] frame];
NSTextView *textView = [[NSTextView alloc] initWithFrame:cFrame];
[aWindow setContentView:textView];
[aWindow makeKeyAndOrderFront:nil];
[aWindow makeFirstResponder:textView];
[textView setString:@"test"];
[textView release];
}
return self;
}
However, the view is empty, with the striped background. If I step through
the code, I noticed that [self window] at this point returns nil, so that
might be a problem.
Any suggestions how to make this work?
thanks,
- Koen.
_______________________________________________
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.