setting up an NSTextView manually
setting up an NSTextView manually
- Subject: setting up an NSTextView manually
- From: David Harper <email@hidden>
- Date: Wed, 27 Jun 2007 15:10:10 -0400 (EDT)
Hi,
I've referred to this document :
http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/AssembleSysByHand.html
and produced the following code:
{
NSTextStorage *textStorage = [[NSTextStorage alloc] init];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
NSRect cFrame = NSMakeRect(100,100,100,100);
NSTextContainer *container = [[NSTextContainer alloc] initWithContainerSize:cFrame.size];
[layoutManager addTextContainer:container];
NSTextView *textView = [[NSTextView alloc] initWithFrame:cFrame textContainer:container];
[myWindow setContentView:textView];
[myWindow makeKeyAndOrderFront:nil];
[textView insertText:@"Text Goes Here"];
[textView setBackgroundColor:[NSColor grayColor]];
[textView release];
[layoutManager release];
[container release];
}
my goal is to set up a text container and text view within a window, that doesn't fill the entire window. When the action that executes this code is invoked, the gray background color of the textView fills the entire window. However, the text container itself is a 100x100 square at the top left of the text view. Why is the cFrame I'm using being ignored? What happened to the origin? I expect that since the text container was placed at the top left of the window, y increases downward in an NSView. Any help is greatly appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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