aboutsummaryrefslogtreecommitdiffstats
path: root/ScrollingTextView.m
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2008-04-02 19:20:20 -0400
committerBrian Cully <bjc@kublai.com>2008-04-02 19:20:20 -0400
commitab10720260e2c184b319026da89f4dfd338500bb (patch)
treea692a27435da0296972e43b21b2f35762e720bfd /ScrollingTextView.m
downloadmoxie-ab10720260e2c184b319026da89f4dfd338500bb.tar.gz
moxie-ab10720260e2c184b319026da89f4dfd338500bb.zip
Initial commit
Diffstat (limited to 'ScrollingTextView.m')
-rw-r--r--ScrollingTextView.m63
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