Re: Setting NSTextView to not wrap text?
Re: Setting NSTextView to not wrap text?
- Subject: Re: Setting NSTextView to not wrap text?
- From: Shaun Wexler <email@hidden>
- Date: Fri, 9 Apr 2004 08:30:35 -0700
On Apr 8, 2004, at 8:22 PM, Greg Titus wrote:
I can agree that it might be nice to have a 'log view' or something
that is a subclass that automatically has this behavior. You could
write one and share it with us, and because Cocoa is so well designed,
you'd only need that one line of code to do it. :-)
Grab my SKWLog.framework and throw it into a project; it captures
STD_ERR and writes to a log file using a separate NSThread which blocks
on read(). To implement the scroll-to-bottom-on-append behavior, I
created a subclass of NSTextView (shown below) that listens for update
notifications, which are coalesced before posting). Framework and
example app:
http://www.skwdev.com/developer/frameworks/SKWLog.dmg
--
Shaun Wexler
MacFOH
http://www.macfoh.com
@interface SKWLogTextView : NSTextView {}
@end
@implementation SKWLogTextView
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer
*)container
{
if ((self = [super initWithFrame:frameRect textContainer:container]))
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(scrollToBottom:)
name:@"SKWLogDidUpdateNotification" object:[self textStorage]];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)scrollToBottom:(NSNotification *)notification
{
[self scrollRangeToVisible:(NSRange){ [[self string] length], 0.0f }];
}
_______________________________________________
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.