Re: scollable custom view
Re: scollable custom view
- Subject: Re: scollable custom view
- From: Sam Goldman <email@hidden>
- Date: Sun, 09 Dec 2001 21:45:35 -0800
David,
It isn't about adding a scrollbar to the view. Instead, you have to group
the custom view into a NSScrollView. To do this in IB, select the view and
goto Layout > Group > Scroll View. Programmatically, you have to make a
scroll view and set your custom view as the content view with the
setContentView:method.
example:
Controller.h
----
IBOutlet NSWindow *mainwindow;
Controller.m
----
NSRect myRect;
NSSize mySize;
NSSize newSize;
NSScrollView *scrollView = [[NSScrollView alloc]
initWithFrame:[mainWindow bounds]];
myRect = [myScrollView bounds];
mySize = NSMakeSize(NSWidth(myRect), NSHeight(myRect));
newSize = [NSScrollView contentSizeForFrameSize:mySize
hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSLineBorder];
myTextView = [[NSTextView alloc]
initWithFrame:NSMakeRect(0,0,newSize.width,newSize.height)];
// Set up the scroll view
[myScrollView setHasVerticalScroller:YES];
[myScrollView setAutoresizingMask:18];
// Set up the text view
[myTextView setAutoresizingMask:18];
// Put text view into the tab view item
[mainWindow setContentView:myScrollView];
[myScrollView setDocumentView:myTextView];
The above might have some problems because it is basically copied, pasted,
and hacked from my own app. You probably won't even need it, but what the
hell, ya know?
- Sam
On 12/9/01 8:33 PM, "David Shaffer" <email@hidden> wrote:
>
Is there any info on how to make a Custom view or an OpenGL view
>
scrollable? How to attach a scrollbar to the view?
>
_______________________________________________
>
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.