Re: How to add NSScrollView automatically?
Re: How to add NSScrollView automatically?
- Subject: Re: How to add NSScrollView automatically?
- From: Andy Lee <email@hidden>
- Date: Fri, 9 Apr 2004 17:20:12 -0400
On Apr 9, 2004, at 3:43 PM, Michael Becker wrote:
However, when I try to put myCustomView in a ScrollView/ClipView-pair,
it doesn't work:
NSClipView *clip = [[ NSClipView alloc]
initWithFrame:NSMakeRect(0,0,300,300)];
NSScrollView *scroll = [[ NSScrollView alloc]
initWithFrame:NSMakeRect(0,0,400,400)];
[ scroll setBorderType:NSBezelBorder];
[ scroll setHasVerticalScroller:YES];
[ scroll setContentView:clip];
The scrollview will create its own clipview, so you don't have to mess
with that.
Here's roughly what I do:
_scrollView = [[NSScrollView alloc] initWithFrame:[self bounds]];
// ... set attributes of _scrollView...
NSTextView *textView =
[[[NSTextView alloc] initWithFrame:[self bounds]] autorelease];
// ... set attributes of textView...
[textView setFrame:[[_scrollView contentView] bounds]];
[_scrollView setDocumentView:textView];
Also are those NSMakeRect()'s providing dummy-information, since the
TabViewItem seems to fit its view to its bounds (which is what I
want). Will the ClipView also be sized to fit the ScrollView?
I don't remember if it mattered or not what rectangles I used; maybe
somebody else knows offhand.
--Andy
_______________________________________________
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.