How can I set scroller position in ScrollView?

Hi,

I’m trying to make scrollView with RTL direction. And I want to set horizontal scroller located in right side, which moved RTL direction.
The bottom line is the code I tried through googling. But It shows an error message. :frowning:
How can I set the scroller to be located in right side?

self.view = DemoView.alloc().init()
self.view.setFrame_(((0, 0), (500, 500)))
self.w.scrollView = ScrollView((5, 5, -5, -50), self.view, autohidesScrollers=True)
	
self.w.scrollView.documentView.scrollPoint_(NSMakePoint(300, 0))

Thanks in advance!

Are you trying to scroll an Edit View? What about Font.currentTab.scrollEditViewToGlyphsAtIndex_(0), would this work for you?

UPDATE: Ah I see, you want to scroll your own NSScrollView. Try scrollView.setVerticalLineScroll_(y) and scrollView.setHorizontalLineScroll_(x). See Apple’s documentation for more info.

Really appreciate your comment.

But, it seems ‘setHorizontalLineScroll_(x)’ is to set scrolling amount.

  • The value of this property is the amount by which the scroll view scrolls itself horizontally when scrolling line by line, expressed in the content view’s coordinate system.

in this documentation , “[scrollview documentView] scrollPoint:newScrollOrigin];” seems to be an answer. But I can’t make it work. It shows an error message like below.
AttributeError: ‘ScrollView’ object has no attribute ‘documentView’

Thanks,

In PyObjC, you will probably have to add parentheses, so it would be documentView(). But the scroll view has a scrollPoint_() method already, so you may not need to resort to the doc view.

1 Like

I would use the self.view.scrollRectToVisible_(rect).

You are mixing vanilla and objectiveC to build your UI. ScrollView() is a vanilla wrapper around the NSScrollview.

1 Like