Scroll View
Scroll View
- Subject: Scroll View
- From: SWC <email@hidden>
- Date: Thu, 18 Oct 2001 23:14:26 -0400
I'm having some trouble getting my scroll view to work properly. After
reading all the documentation (NSView, NSScrollView, NSClipView), I'm
afraid I'm just not understanding the heirarchy of subviews well enough
to determine what I need to set.
I have an image view which sits inside of a scroll view. When I open an
image, I want the image view to equal the size of the image. I then
want to scroll view so that the upper left part of the image is in the
upper left corner of the displayed rect. I was able to get the image to
scroll to the proper position, but I'm having trouble getting the
content of the scroll view to be limited to the size of the image...in
other words, you can scroll down and right far beyond the bottom
rightmost corner of the image, which is what I want to prevent.
Here is the (some hasty) code I've got so far: (this code is right
after the open panel sheet returns from the user selecting what image to
open)
NSPoint thePoint = {0,0};
path = [sheet filename];
originalImage = [[NSImage alloc] initWithContentsOfFile: path];
[mainImageView setImage: originalImage];
thePoint.y = [mainImageView bounds].size.height;
[mainImageView scrollPoint:thePoint ];
Any help on this is greatly appreciated.
Spencer