Syncing vertical scrollbar with document view?

  • I have a small NSScrollView which is used to navigate (using scroll bars)
    over a very large preloaded topographical map in a custom document view.
    When the app launches, the horizontal scroller is at the LHS, where it
    should be, but the vertical scroll position is at the very BOTTOM, and
    displays the bottom of the map in the view. Of course, I would like to
    display the TOP by default!

    How can I do this?

    If I set the vertical scroller's position with setFloatValue: only the
    scroll bar goes to the top. The document view doesn't reflect the
    repositioning of the scroll bar, and it still displays the bottom of the map
    -- until I click on the scroll bar at runtime. Only then will the map view
    display the top portion. Using [scrollView reflectScrolledClipView:] doesn't
    have any effect. I've even tried performClick: on the repositioned scroller
    (since clicking on the scroller interactively syncs the scroller & view),
    but it, too, has no effect.

    Scrolling the map view with scrollToPoint: doesn't help either, since it's
    already positioned at NSPoint(0,0) where it should be. (Scrolling it down
    only causes blank space to appear at the top of the map when the scroller is
    moved to the top.)

    Thanks!
    Alex
  • On Tue, 01 Feb 2005 14:53:43 -0600, "Alex Majora" <a_c_majora...>
    said:
    > I have a small NSScrollView which is used to navigate (using scroll bars)
    > over a very large preloaded topographical map in a custom document view.
    > When the app launches, the horizontal scroller is at the LHS, where it
    > should be, but the vertical scroll position is at the very BOTTOM, and
    > displays the bottom of the map in the view. Of course, I would like to
    > display the TOP by default!
    >
    > How can I do this?
    >
    > If I set the vertical scroller's position with setFloatValue: only the
    > scroll bar goes to the top. The document view doesn't reflect the
    > repositioning of the scroll bar, and it still displays the bottom of the map
    > -- until I click on the scroll bar at runtime. Only then will the map view
    > display the top portion. Using [scrollView reflectScrolledClipView:] doesn't
    > have any effect. I've even tried performClick: on the repositioned scroller
    > (since clicking on the scroller interactively syncs the scroller & view),
    > but it, too, has no effect.
    >
    > Scrolling the map view with scrollToPoint: doesn't help either, since it's
    > already positioned at NSPoint(0,0) where it should be. (Scrolling it down
    > only causes blank space to appear at the top of the map when the scroller is
    > moved to the top.)

    Basically, it's just a matter of RTFM. There are two things you seem not to
    understand. First, the position of the vertical scroller has nothing to do
    with the matter, and it isn't your business to go setting it; if you want to
    change the scroll position, you set the origin of the clip view. Second, you
    evidently don't even know how coordinates work in Cocoa, since you think
    that (0,0) is "where it should be", but this implies that you don't realize
    that (0,0) is the bottom, not the top which is what you want. So just read
    up on NSView and how scrolling works, and all will be perfectly clear. m.

    --
    matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    A fool + a tool + an autorelease pool = cool!
    AppleScript: the Definitive Guide
    <http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
  • On Wed, 02 Feb 2005 20:35:32 -0800 Matt Neuburg wrote:

    > if you want to change the scroll position, you set the origin of the clip
    > view.

    Ah, this is the point I was overlooking!

    I had been inadvertently setting my documentView's origin, not [documentView
    superview], which is my clipView. It works quite well now!

    Thanks so much!
    Alex
  • On Thu, 03 Feb 2005 12:13:05 -0600, "Alex Majora" <a_c_majora...>
    said:
    > On Wed, 02 Feb 2005 20:35:32 -0800 Matt Neuburg wrote:
    >
    >> if you want to change the scroll position, you set the origin of the clip
    >> view.
    >
    > Ah, this is the point I was overlooking!
    >
    > I had been inadvertently setting my documentView's origin, not [documentView
    > superview], which is my clipView. It works quite well now!

    In all fairness, this is not entirely your fault. The docs are written
    extraordinarily badly at the critical juncture. In particular, this
    sentence:

    "The content view positions the document view by altering its bounds
    rectangle"

    ...is horrendously misleading with respect to the antecedent of the word
    "its", and would not have gotten past my third-grade English teacher. m.

    --
    matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    A fool + a tool + an autorelease pool = cool!
    AppleScript: the Definitive Guide
    <http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
previous month february 2005 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28            
Go to today
MindNode
MindNode offered a free license !