How To Get The Scrollwidth After Create A Scrollview?

Hi all,

I have a question about scrollView.

If I create a scrollview like this:

 local scrollView = widget.newScrollView{
  width = _H*1.32,
  height = _W*1.52,
  bgColor = { 255, 255, 255, 192 },
  listener = scrollViewListener
 } 

then I insert some object into it.  The scrollWidth will be changed.

How can I get the scrollWidth after changing?

Can anyone give me some advices?

Thank you very much.

Does scrollView.width not return the right value?

Does scrollView.width not return the right value?

scrollView.width, scrollView.contentWidth and scrollView.contentBounds.xMax all report the same value, even if the scrollView has a significant amount of horizontal content.

It appears there is no way to test for contentWidth, which means I have to abandon converting my project to Graphics 2.0. :frowning:

EDIT: gosh, just noticed that was a 2013 post…but as best I can tell, there’s no solution today either?

A scrollView’s “group” is a container.  I suspect that the .width and  .contentWidth are returning the width of the container. 

Have you tried view._scrollWidth?  I don’t like recommending using private variables but it might have what you’re looking for.

Thanks for trying Rob, but that variable does not exist. Nor does scrollView.view, for that matter. A cursory pairs() check doesn’t seem to reveal any similar variable.

I believe what you are looking for is this:
 

scrollView.\_view.contentHeight -- returns current height of scrollView scrollView.\_view.contentWidth -- returns current width of scrollView
scrollView.\_view.contentHeight -- returns current height of scrollView scrollView.\_view.contentWidth -- returns current width of scrollView

Perfect; that works. Thanks, eja :slight_smile:

scrollView.width, scrollView.contentWidth and scrollView.contentBounds.xMax all report the same value, even if the scrollView has a significant amount of horizontal content.

It appears there is no way to test for contentWidth, which means I have to abandon converting my project to Graphics 2.0. :frowning:

EDIT: gosh, just noticed that was a 2013 post…but as best I can tell, there’s no solution today either?

A scrollView’s “group” is a container.  I suspect that the .width and  .contentWidth are returning the width of the container. 

Have you tried view._scrollWidth?  I don’t like recommending using private variables but it might have what you’re looking for.

Thanks for trying Rob, but that variable does not exist. Nor does scrollView.view, for that matter. A cursory pairs() check doesn’t seem to reveal any similar variable.

I believe what you are looking for is this:
 

scrollView.\_view.contentHeight -- returns current height of scrollView scrollView.\_view.contentWidth -- returns current width of scrollView
scrollView.\_view.contentHeight -- returns current height of scrollView scrollView.\_view.contentWidth -- returns current width of scrollView

Perfect; that works. Thanks, eja :slight_smile: