ScrollView text limit?

Hello Everyone,

I am facing a problem with newScrollView. Actually I’ve a huge amount of text and I’m using scroll view. It’s working fine if the text is not quite long enough but it fails when the text is huge.

Here is my code

local getText local options = {    text = "",    x = 0,    y = 0,    font = "OpenSans-Regular.ttf",    fontSize = 24,    width = display.contentWidth - 15,    height = 0,    align = "left"    } local function scrollListener( event )       if ( event.limitReached ) then         if ( event.direction == "left" ) then nextSceneFunc()         elseif ( event.direction == "right" ) then prevSceneFunc()         end     end     return true end local scrollView = widget.newScrollView(     {         top = 180,         left = 3,         width = display.contentWidth + 4,         height = display.contentHeight - 178,         topPadding = 10,         bottomPadding = 10,         horizontalScrollDisabled = false,         verticalScrollDisabled = false,         hideBackground = true,                 listener = scrollListener     } ) local function displayText()             getText = display.newText(options)             getText:setTextColor(0, 0, 0)     getText.text = "a lot of text here"     getText.anchorY = 0                 scrollView:insert(getText)      end function main()         displayText();     end main()

I have also attached a screenshot.

Any help would be highly appreciated.

Thanks,

Hi,

This is because your  text is to big. Corona render your text into a texture and there is a maximum size for the texture depending of the device. This is why your text will be cut at some point.

The solution is to simply break your text. We have face this issue in our tourism app as sometime description of a point of interest can be very long. Use a loop with string.gmatch will do the trick.

Pseudo code :

for eachLine in string.gmatch(yourTextString, “[^\n\n]+”) do

    display.newText(…)

end

Nick

Thanks for the reply.

I will try to implement what you said…

Ty Nick

Hi,

This is because your  text is to big. Corona render your text into a texture and there is a maximum size for the texture depending of the device. This is why your text will be cut at some point.

The solution is to simply break your text. We have face this issue in our tourism app as sometime description of a point of interest can be very long. Use a loop with string.gmatch will do the trick.

Pseudo code :

for eachLine in string.gmatch(yourTextString, “[^\n\n]+”) do

    display.newText(…)

end

Nick

Thanks for the reply.

I will try to implement what you said…

Ty Nick