Re: scrollPoint in NSScrollView does not scroll
Re: scrollPoint in NSScrollView does not scroll
- Subject: Re: scrollPoint in NSScrollView does not scroll
- From: Keary Suska <email@hidden>
- Date: Mon, 17 Jun 2013 08:38:06 -0600
On Jun 13, 2013, at 5:53 PM, Benjamin Rindt wrote:
> Hey,
> I'm trying this for I think over 3 hours just to get my View to scroll to a point when loaded. But not to start and cut off the rest of it, just be scrolled to there.
>
> Tried it in my real project, didn't work, made small test project, doesn't work either.
>
> NSScrollView* myscrollview = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
> NSClipView* myclipview = [[NSClipView alloc] initWithFrame:NSMakeRect(0, 0, 500, 400)];
> [myscrollview setHasVerticalScroller:YES];
> [myscrollview setHasHorizontalScroller:YES];
> [myscrollview setDocumentView:myclipview];
>
> [[myscrollview documentView] scrollPoint:NSMakePoint(300.0, 300.0)];
>
> [self.window.contentView addSubview:myscrollview];
>
>
> but this isn't scrolling anywhere. I'm shure I'm missing something. Thanks for reply!
It may not matter but NSClipView's -scrollToPoint: is the method to use. One possibility I know I have missed in the past is that the scroll point is the clip view's bounds *origin*, which is the bottom-left corner. Also, this simple test won't work unless the document view is larger than the view port (the visible frame of the scroll view) by enough that you will get a visible scroll effect.
Also, if the document view is an NSTextView, it might have some layout to do before the size is known so you might have to wait until the view is displayed before you can scroll.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden