• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: scollable custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


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

  • Prev by Date: notification before dockMenu is shown
  • Next by Date: How to get scripting to work without NSApplication
  • Previous by thread: scollable custom view
  • Next by thread: How to get scripting to work without NSApplication
  • Index(es):
    • Date
    • Thread