Avoid smooth scrolling when scrolling programmatically

36 views
Skip to first unread message

Stefan Haller

unread,
Sep 12, 2011, 3:07:13 AM9/12/11
to coco...@lists.apple.com
I need to set the scroll position of my NSScrollView programmatically,
and I don't want it to scroll smoothly (if the user's "smooth scrolling"
preference is on). I can't find a way how to do that.

Calling scrollPoint: on my document view results in smooth scrolling. I
thought that removing the scroll view from its superview before and
adding it back afterwards would prevent this, but it doesn't.

I also tried calling setBoundsOrigin: on the content view instead, but
it also results in an animation (although only sometimes, and in
different cases than with scrollPoint; I haven't been able to figure out
the details yet).

I guess I could mess with NSUserDefaults, turning off smooth scrolling
before calling scrollPoint and restoring it to what it was before
afterwards, but this seems like a hack to me.

Any other ideas?


--
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Kyle Sluder

unread,
Sep 12, 2011, 2:23:33 PM9/12/11
to Stefan Haller, coco...@lists.apple.com
On Mon, Sep 12, 2011 at 12:07 AM, Stefan Haller <li...@haller-berlin.de> wrote:
> I need to set the scroll position of my NSScrollView programmatically,
> and I don't want it to scroll smoothly (if the user's "smooth scrolling"
> preference is on).  I can't find a way how to do that.

Why would you not want to scroll smoothly if the user has decided they
like smooth scrolling?

--Kyle Sluder

Stefan Haller

unread,
Sep 12, 2011, 3:22:17 PM9/12/11
to Kyle Sluder, coco...@lists.apple.com
Kyle Sluder <kyle....@gmail.com> wrote:

> On Mon, Sep 12, 2011 at 12:07 AM, Stefan Haller <li...@haller-berlin.de> wrote:
> > I need to set the scroll position of my NSScrollView programmatically,
> > and I don't want it to scroll smoothly (if the user's "smooth scrolling"
> > preference is on). I can't find a way how to do that.
>
> Why would you not want to scroll smoothly if the user has decided they
> like smooth scrolling?

Imagine a master-detail interface with a master list of "documents" and
a detail view showing one document. Clicking on a different document in
the master list loads the new document into the detail pane's scroll
view, and then scrolls it to the top.


--
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/

Reply all
Reply to author
Forward
0 new messages