TextSizingExample
TextSizingExample
- Subject: TextSizingExample
- From: Koen van der Drift <email@hidden>
- Date: Thu, 23 Jan 2003 09:58:06 -0500
Hi,
Based on the two column code in the TextSizingExample in
/Developer/Examples/AppKit/, I created an view with two columns. How do I
make sure that text only appears in the right column? If I set some text
for the right view at startup using setString, the text indeed appears only
in the right column, but if I select text, the selection outline extends to
both columns.
If I don't set a string at startup, the insertion point is in the left
column, and typing continues into the left column.
Here's a snippet (sorry for the long lines):
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer
*)container
{
NSRect frame;
NSTextContainer *textContainer;
NSTextView *textView;
if ( self = [super initWithFrame:frameRect textContainer:container] )
{
frame = [self bounds];
// Create and configure first NSTextContainer
textContainer = [[NSTextContainer allocWithZone:[self zone]]
initWithContainerSize:NSMakeSize(40.0,
frame.size.height)];
[[self layoutManager] addTextContainer:textContainer];
[textContainer release];
// Create and configure first NSTextView
textView = [[NSTextView allocWithZone:[self zone]]
initWithFrame:NSMakeRect(frame.origin.x, frame.origin.y,
40.0, frame.size.height) textContainer:textContainer];
[textView release];
// Create and configure second NSTextContainer
textContainer = [[NSTextContainer allocWithZone:[self zone]]
initWithContainerSize:NSMakeSize(frame.size.width - 40.0 - 8.0,
frame.size.height)];
[[self layoutManager] addTextContainer:textContainer];
[textContainer release];
// Create and configure second NSTextView
textView = [[NSTextView allocWithZone:[self zone]]
initWithFrame:NSMakeRect(frame.origin.x +
40.0 + 8.0, frame.origin.y,
frame.size.width - 40.0 - 8.0,
frame.size.height) textContainer:textContainer];
[textView setAllowsUndo:YES];
[textView setRichText:NO];
[textView setFont:[NSFont fontWithName: @"Courier" size:14]];
[textView setString: @"some init string"];
[textView release];
}
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.