how to keep text from going off the screen, from a new new line

ok my question is this, i know how to put text on the screen and make it a certain length before it drops down and inputs the rest of the text, but i do not know how it works when theres a button involved, here is the code and i want whats in the list to drop down since i have the text drop down already but when i change text on thee same screen it runs off screen.  im talking about the sentences that are in local list of things to say.  

[lua]

local storyboard = require(“storyboard”)

    local scene = storyboard.newScene()

    

    local widget = require (“widget”)

     

    

    

    function scene:createScene(event)

        local gameGroup = self.view

        

        

       local background = display.newImage(“default.png”,0,0, display.contentWidth, display.contentHeight)

background.x = 160

background.y = 240

background:scale(.90,1.20)

        

         local function menuTouch(event)

            if event.phase == “ended” then

                storyboard.gotoScene(“menuscreen”)

            end

         end

         local list_of_things_to_say = { “alpha,beta,charlie,deltaaaaaaaaaaaaaaaaaaa,eckoooooooooooooooooo, foxtrot, kelllooooooooooooooooooooooooooooooooooooooooooo”,"the dog wanted the tennis ball thrown in the pool so i lunched it in the pool as he went to get it.  " }

-----display text

local myText = display.newText( "hello ", 150, 200, native.systemFont, 20 )

– event handler must be defined before creating button with widget.newButton()

 local function onObjectTouch( event )

    if event.phase == “ended” then

        if #list_of_things_to_say > 0 then

             – calculate random index

             local idx = math.random(1, #list_of_things_to_say)

             – set the text property of your text object to the string at given index of list_of_things_to_say

             myText.text = list_of_things_to_say[idx]

            – remove this string from the table so that it cannot be used again

            table.remove(list_of_things_to_say, idx)

        else – if there’s no more things to say

myText.text = “No more things to say”

        end

    end

     return true

end           

----button

local rndmtxt = widget.newButton

{

    left = 160,

    top = 410,

    id = “newQuestionbtn”,

    label = “New question?”,

    onEvent = onObjectTouch

}

     

     

     

         local menu = widget.newButton

            {

               left = -25,

               top = 410,

               id = “menuscreen”,

               label = “menu”,

               onEvent = menuTouch

            }

     

     

    

        gameGroup:insert(background)

        gameGroup:insert(menu)

        gameGroup:insert(rndmtxt)

        gameGroup:insert(myText)

        

    end

     

     

    

    function scene:enterScene(event)

    end

     

    function moveToScene()

    end

     

    function scene:exitScene(event)

    end

     

    function scene:destroyScene( event )

    end

     

     

    scene:addEventListener(“createScene”, scene)

    scene:addEventListener(“enterScene”, scene)

    scene:addEventListener(“exitScene”, scene)

    scene:addEventListener(“destroyScene”, scene)

    

    return scene

[/lua]

You need to set the height and width parameter when you create your newText object:

display.newText( [parentGroup,] text, x, y [, width, height], font [, fontSize] ) 

https://docs.coronalabs.com/api/library/display/newText.html

-----display text local myText = display.newText( "hello ", 150, 200, 200, 200, native.systemFont, 20 )

This will however cause the lines to just break when the character limit has been reached which can (and will) be in the middle of the word. Read here for more information:

https://coronalabs.com/blog/2014/06/17/tutorial-working-with-large-blocks-of-text/

Best regards,

Tomas

You need to set the height and width parameter when you create your newText object:

display.newText( [parentGroup,] text, x, y [, width, height], font [, fontSize] ) 

https://docs.coronalabs.com/api/library/display/newText.html

-----display text local myText = display.newText( "hello ", 150, 200, 200, 200, native.systemFont, 20 )

This will however cause the lines to just break when the character limit has been reached which can (and will) be in the middle of the word. Read here for more information:

https://coronalabs.com/blog/2014/06/17/tutorial-working-with-large-blocks-of-text/

Best regards,

Tomas