diff options
Diffstat (limited to 'ScrollingTextView.m')
-rw-r--r-- | ScrollingTextView.m | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ScrollingTextView.m b/ScrollingTextView.m new file mode 100644 index 0000000..196cf28 --- /dev/null +++ b/ScrollingTextView.m @@ -0,0 +1,63 @@ +#import "ScrollingTextView.h" + +@implementation ScrollingTextView +- (id)initWithFrame: (NSRect)aFrame +{ + self = [super initWithFrame: aFrame]; + [[self layoutManager] setDelegate: self]; + return self; +} + +- (void)layoutManager: (NSLayoutManager *)aLayoutManager +didCompleteLayoutForTextContainer: (NSTextContainer *)aTextContainer + atEnd:(BOOL)flag +{ + if (flag) { + NSClipView *clipView; + + clipView = (NSClipView *)[self superview]; + if ([clipView isKindOfClass: [NSClipView class]]) { + [clipView scrollToPoint: + [clipView constrainScrollPoint: NSMakePoint(0.0, [self frame].size.height)]]; + [[clipView superview] reflectScrolledClipView: clipView]; + } + } +} + +- (BOOL)performKeyEquivalent: (NSEvent *)anEvent +{ + NSDocument *targetDoc; + BOOL rc; + + rc = NO; + targetDoc = [[[self window] windowController] document]; + if ([targetDoc respondsToSelector: @selector(handleEvent:from:)]) + rc = [[targetDoc performSelector: @selector(handleEvent:from:) + withObject: anEvent + withObject: self] boolValue] ? YES : [super performKeyEquivalent: anEvent]; + return rc; +} + +- (void)keyDown: (NSEvent *)anEvent +{ + if ([[self delegate] respondsToSelector: @selector(handleEvent:from:)]) { + if ([[[self delegate] performSelector: @selector(handleEvent:from:) withObject: anEvent + withObject:self] boolValue] == NO) + [super keyDown: anEvent]; + } else + [super keyDown: anEvent]; +} + +- (void)keyDownToSuper: (NSEvent *)anEvent +{ + [super keyDown: anEvent]; +} + +- (void)changeFont: (id)sender +{ + if ([[self delegate] respondsToSelector: @selector(changeFont:)]) { + [[self delegate] performSelector: @selector(changeFont:) + withObject: sender]; + } +} +@end |