display.newText API Docs

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

Not sure if this indicates a build (since it links to one) that the API is against, or if the docs were updated via

Revision2018.3340

Either way, the API describes:

width (optional)

Number. If supplied, text will be wrapped at this width.

 

When i use the text string:

 

                local group = display.newGroup()

                local tmp = display.newText({

                    parent = group,

                    text = “[General] testQUXXE: testing time - 1533400997 super duper ever any way can this work”,

                    width = 400

                })

I don’t see it wrapping. This seems like the docs are incorrect or a bug in the existing build. Can someone tell me if I’m missing something that would explain this inconsistency?

How is it not working? I used this simple project (with an 800x1200 config.lua):
 

local centerX, centerY = display.contentCenterX, display.contentCenterY local group = display.newGroup() local tmp = display.newText({ parent = group, text = "[General] testQUXXE: testing time - 1533400997 super duper ever any way can this work", width = 400 }) tmp.x = centerX tmp.y = centerY tmp:setFillColor(1)

and this is what I see in the simulator:

Rob

This is very odd. When in a tableView, it does not.

local widget = require( "widget" ) local screenLeft = display.screenOriginX local screenWidth = display.contentWidth - screenLeft \* 2 local screenTop = display.screenOriginY local screenHeight = display.contentHeight - screenTop \* 2 local screenTopSB = display.screenOriginY + display.topStatusBarContentHeight local screenHeightSB = display.contentHeight - screenTopSB local group = display.newGroup() --local background = display.newImageRect( group, "bg.jpg", screenWidth, screenHeightSB ) --background.x = screenWidth/2 --background.y = screenHeightSB/2+display.topStatusBarContentHeight local topRect = display.newRect( group, screenWidth/2, screenTopSB, screenWidth, 300 ) topRect:setFillColor(0.5,1,0) local textToAdd = "Testing time - "..os.time(os.date("!\*t")).." --------- ----------- ----------- ---------- -------" local tableView = widget.newTableView({ left = screenLeft, top = screenTopSB+200, width = screenWidth, height = screenHeightSB-200, hideBackground = true, noLines = true, topPadding = 30, bottomPadding = 30, isBounceEnabled = false, hideScrollBar = true }) function testCase1NoCustomRender() local msgText = "[start]"..textToAdd..textToAdd..textToAdd local newTextObj = display.newText({ text = msgText, width = screenWidth }) local msgHeight = newTextObj.height print("Msg Height calculated to be:"..msgHeight.." width:"..screenWidth) tableView:insertRow(newTextObj) end function testCase2CustomRender() local tableView2 = widget.newTableView({ left = screenLeft, top = screenTopSB+200, width = screenWidth, height = screenHeightSB-200, hideBackground = true, noLines = true, topPadding = 30, bottomPadding = 30, isBounceEnabled = false, hideScrollBar = true, onRowRender = function( event ) -- Get reference to the row group local row = event.row local rowParent = event.row local rowWidth = row.contentWidth local rowHeight = row.contentHeight print("rowWidth:"..rowWidth) print("rowHeight:"..rowHeight) local containerPanel = display.newRect(rowParent, rowWidth/2, rowHeight/2, screenWidth, rowHeight) containerPanel:setFillColor(1) print("render row:"..row.params.message) local rowTitle = display.newText({ parent = rowParent, text = row.params.message, x = 15, y = 45/2 }) rowTitle:setFillColor( 0 ) rowTitle.anchorX = 0 end }) local msgText = "[start]"..textToAdd..textToAdd..textToAdd print("msg:"..msgText) local group = display.newGroup() local tmp = display.newText({ parent = group, text = msgText, width = 400 }) local msgHeight = tmp.height print("Msg Height calculated to be:"..msgHeight.." width:"..screenWidth) group:removeSelf() group = nil tableView2:insertRow{ isCategory = false, rowHeight = msgHeight, rowColor = { default = { 255, 255, 255, 0 } }, params = { message = msgText } } end --testCase1NoCustomRender() testCase2CustomRender()

Your display.newText() in your onRowRender() function never specifies a width:

 local rowTitle = display.newText({ parent = rowParent, text = row.params.message, x = 15, y = 45/2 })

Rob

How is it not working? I used this simple project (with an 800x1200 config.lua):
 

local centerX, centerY = display.contentCenterX, display.contentCenterY local group = display.newGroup() local tmp = display.newText({ parent = group, text = "[General] testQUXXE: testing time - 1533400997 super duper ever any way can this work", width = 400 }) tmp.x = centerX tmp.y = centerY tmp:setFillColor(1)

and this is what I see in the simulator:

Rob

This is very odd. When in a tableView, it does not.

local widget = require( "widget" ) local screenLeft = display.screenOriginX local screenWidth = display.contentWidth - screenLeft \* 2 local screenTop = display.screenOriginY local screenHeight = display.contentHeight - screenTop \* 2 local screenTopSB = display.screenOriginY + display.topStatusBarContentHeight local screenHeightSB = display.contentHeight - screenTopSB local group = display.newGroup() --local background = display.newImageRect( group, "bg.jpg", screenWidth, screenHeightSB ) --background.x = screenWidth/2 --background.y = screenHeightSB/2+display.topStatusBarContentHeight local topRect = display.newRect( group, screenWidth/2, screenTopSB, screenWidth, 300 ) topRect:setFillColor(0.5,1,0) local textToAdd = "Testing time - "..os.time(os.date("!\*t")).." --------- ----------- ----------- ---------- -------" local tableView = widget.newTableView({ left = screenLeft, top = screenTopSB+200, width = screenWidth, height = screenHeightSB-200, hideBackground = true, noLines = true, topPadding = 30, bottomPadding = 30, isBounceEnabled = false, hideScrollBar = true }) function testCase1NoCustomRender() local msgText = "[start]"..textToAdd..textToAdd..textToAdd local newTextObj = display.newText({ text = msgText, width = screenWidth }) local msgHeight = newTextObj.height print("Msg Height calculated to be:"..msgHeight.." width:"..screenWidth) tableView:insertRow(newTextObj) end function testCase2CustomRender() local tableView2 = widget.newTableView({ left = screenLeft, top = screenTopSB+200, width = screenWidth, height = screenHeightSB-200, hideBackground = true, noLines = true, topPadding = 30, bottomPadding = 30, isBounceEnabled = false, hideScrollBar = true, onRowRender = function( event ) -- Get reference to the row group local row = event.row local rowParent = event.row local rowWidth = row.contentWidth local rowHeight = row.contentHeight print("rowWidth:"..rowWidth) print("rowHeight:"..rowHeight) local containerPanel = display.newRect(rowParent, rowWidth/2, rowHeight/2, screenWidth, rowHeight) containerPanel:setFillColor(1) print("render row:"..row.params.message) local rowTitle = display.newText({ parent = rowParent, text = row.params.message, x = 15, y = 45/2 }) rowTitle:setFillColor( 0 ) rowTitle.anchorX = 0 end }) local msgText = "[start]"..textToAdd..textToAdd..textToAdd print("msg:"..msgText) local group = display.newGroup() local tmp = display.newText({ parent = group, text = msgText, width = 400 }) local msgHeight = tmp.height print("Msg Height calculated to be:"..msgHeight.." width:"..screenWidth) group:removeSelf() group = nil tableView2:insertRow{ isCategory = false, rowHeight = msgHeight, rowColor = { default = { 255, 255, 255, 0 } }, params = { message = msgText } } end --testCase1NoCustomRender() testCase2CustomRender()

Your display.newText() in your onRowRender() function never specifies a width:

 local rowTitle = display.newText({ parent = rowParent, text = row.params.message, x = 15, y = 45/2 })

Rob