widget:scrollTo -> "top" doesn't work?

Hello everybody,

I’m using this little code -> view:scrollTo( “top”, { time = 500 } ) to let the scrollview scroll to the newest content.

But nothing happens.

If I use “bottom” instead of “top” everything works, but in the opposite way…

Maybe it’s a bug, I don’t know.

Its not the bug its simply that your scroll view is already at the top. 

Try this chunk of code:

local function aa ()
scrollView:scrollTo( “top”, { time=1200} )
end
scrollView:scrollTo( “bottom”, { time=1200, onComplete=aa } )

first it scrolls to bottom then top. :slight_smile: so scrollTo works perfectly.

When scrollView is created its by default at “top” so it won’t scroll to it.

Hmm, thanks for response.

The point is that I’m calling one string of messages from mysql database.

So I’m creating just one text and insert the whole string (\n included to make breaks).

So problem is, if someone writes a message and there a bunch of messages, the message goes in the bottom of textview, and it is unreadable, I need to scroll to bottom/top? AND I need auto sizing scrollview.

Your code doesn’t even do nothing…

Nevermind.

The scrollView does autosize.

Rob

Ah Rob, fixed this. The solution is:

object:setScrollHeight( object.contentHeight )

Use this in connection with timer to have the scrollHeight sizefitted to the content.

Its not the bug its simply that your scroll view is already at the top. 

Try this chunk of code:

local function aa ()
scrollView:scrollTo( “top”, { time=1200} )
end
scrollView:scrollTo( “bottom”, { time=1200, onComplete=aa } )

first it scrolls to bottom then top. :slight_smile: so scrollTo works perfectly.

When scrollView is created its by default at “top” so it won’t scroll to it.

Hmm, thanks for response.

The point is that I’m calling one string of messages from mysql database.

So I’m creating just one text and insert the whole string (\n included to make breaks).

So problem is, if someone writes a message and there a bunch of messages, the message goes in the bottom of textview, and it is unreadable, I need to scroll to bottom/top? AND I need auto sizing scrollview.

Your code doesn’t even do nothing…

Nevermind.

The scrollView does autosize.

Rob

Ah Rob, fixed this. The solution is:

object:setScrollHeight( object.contentHeight )

Use this in connection with timer to have the scrollHeight sizefitted to the content.