scroll view & pinned edge during resize
scroll view & pinned edge during resize
- Subject: scroll view & pinned edge during resize
- From: Daryn <email@hidden>
- Date: Thu, 2 Oct 2003 15:53:08 -0500
Help, I'm stumped.
I'd like to be able to specify a scroll view's edge to pin during a
resize. For example, I'd like a text view that has the bottom edge
pinned. I thought I could simply use a subclass of NSScrollView like
this:
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize {
NSRect oldRect = [self documentVisibleRect];
[super resizeWithOldSuperviewSize:oldBoundsSize];
NSRect newRect = [self documentVisibleRect];
// determine new origin
NSPoint point = oldRect.origin;
point.y += oldRect.size.height - newRect.size.height;
if (point.y < 0.0) point.y = 0.0;
// scroll if necessary
if (point.y != oldRect.origin.y) [[self documentView]
scrollPoint:point];
// sanity check that it's where it's supposed to be...
newRect = [self documentVisibleRect];
if (newRect.origin.y != point.y)
NSLog(@"oops! %f != %f <-
%f",newRect.origin.y,point.y,oldRect.origin.y);
}
Enlarging the window with the text view works correctly. Shrinking the
window quickly doesn't always work right -- a number of "oops!"
statements are generated. The view only scrolled about 50% of the
expected distance.
If I stick 2 of these custom scroll views into a split view and resize
the slider, then the view resizing & pinning works perfectly. The
issue is specific to the window resizing the view. Is this not the
right point in the view machinery to implement such a feature? Or am I
doing something stupid in the above routine?
Daryn
_______________________________________________
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.