Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scollable custom view



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.


References: 
 >scollable custom view (From: David Shaffer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.