why doesn't my scrollview scroll ...
why doesn't my scrollview scroll ...
- Subject: why doesn't my scrollview scroll ...
- From: Martin Redington <email@hidden>
- Date: Fri, 2 Jun 2006 14:30:05 +0100
I followed the recipe at:
http://developer.apple.com/documentation/Cocoa/Conceptual/TextUILayer/
Tasks/TextInScrollView.html
as below, but my scroll view refuses to scroll (the scroll bar never
gets activated), although I can move up and down in the document fine.
#import "TestScrollViewController.h"
#define DEFAULT_TEXTAREA_HEIGHT 66.0f
#define DEFAULT_TEXTAREA_WIDTH 200.0f
@implementation TestScrollViewController
- (NSView *) textArea{
float textAreaFrameRectWidth = DEFAULT_TEXTAREA_WIDTH;
float textAreaFrameRectHeight = DEFAULT_TEXTAREA_HEIGHT;
NSRect textAreaFrameRect = NSMakeRect(0.0f, 0.0f,
textAreaFrameRectWidth, textAreaFrameRectHeight);
NSScrollView *scrollView = [[NSScrollView alloc]
initWithFrame:textAreaFrameRect];
[scrollView setBorderType:NSBezelBorder];
[scrollView setHasHorizontalScroller:NO];
[scrollView setHasVerticalScroller:YES];
[scrollView setAutoresizingMask:(NSViewWidthSizable |
NSViewHeightSizable)];
// doesn't seem to make any difference.
// [[scrollView contentView] setAutoresizesSubviews:YES];
NSSize scrollViewContentSize = [scrollView contentSize];
NSTextView *textArea = [[NSTextView alloc]
initWithFrame:NSMakeRect(0.0f, 0.0f, scrollViewContentSize.width,
scrollViewContentSize.height)];
[textArea setMinSize:NSMakeSize(scrollViewContentSize.width,
scrollViewContentSize.height)];
[textArea setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[textArea setVerticallyResizable:YES];
[textArea setHorizontallyResizable:NO];
[textArea setAutoresizingMask:NSViewWidthSizable];
[[textArea textContainer] setContainerSize: NSMakeSize
(scrollViewContentSize.width, FLT_MAX)];
[[textArea textContainer] setWidthTracksTextView: YES];
[scrollView setDocumentView:textArea];
return scrollView;
}
////////////////////////////////////////////////
- (void) awakeFromNib
{
NSView *view = [self viewForDictionary:nil];
// _window is an IBOutlet to the main window
[[_window contentView] addSubview:[self textArea]];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden