Reversed scrollbar?

I have a vertical scrollbar that I use to scroll a view up and down in a larger virtual image. The graph has a range from -4100 to 3600. I set my vertical scrollbar’s overall range using setRangeLimits( -4100, 3600 ), and initially set the current view range using setCurrentRange( -1000, 1000 ). That looks fine.

But when I drag the scrollbar up or down, the values go in the opposite direction from what they should. For example, dragging up shows a smaller value for newRangeStart in the scrollBarMoved() callback. (The drawings I see in the graph move upwards, when they should move downward because we’re scrolling up in the virtual image, which should increase the current range’s start position.)

Is there some way to change that behavior? I didn’t see anything in the Scrollbar class to do that.

Since I’m not getting a change value, but a new absolute value, I can’t just reverse the value I’m given. Is this driven by the mouse trackpad settings on my Mac laptop? If so, how can I make it always behave the way I want?

Ah, I see. The vertical scrollbar range goes from the top of the screen towards the bottom of the screen, while my graph has increasing values going up on the screen. Guess I need to subtract from the max when translating between scrollbar and graph. Makes sense.

Hmm, that’s not the right solution, though. A little more complex, but I’ll get it.