Hi
I have a tableview and the rows have a lot of information. I want to wrap the text per row so that it stays in the row and doesn’t trail off the screen to the right. How can I do a new line character or wrap text within a row.
Thanks
Hi
I have a tableview and the rows have a lot of information. I want to wrap the text per row so that it stays in the row and doesn’t trail off the screen to the right. How can I do a new line character or wrap text within a row.
Thanks
I don’t believe the text entries natively observe the groups/widgets into which they are inserted. You will most likely have to modify the width of the newText() object so that it reflects the bounds of your rows:
https://docs.coronalabs.com/api/library/display/newText.html#width-height-optional
Alex is right, you have to use display.newText() in multi-line mode (i.e. specify a width and optional height to try and fit the text into). But that said… The user experience for a tableView is to show many rows of limited information on the screen. The user interacts with the row to see the more in depth details on a screen dedicated to that entry.
Trying to fit too much information into a tableView row is not something your users are going to expect.
Rob
Thanks for the replys guys. I looked into it and tried making that change but I think I am doing it wrong. I need it to be multiple lines becuase I am using the rows as read only like Lifeline text based game. The user doesn’t click on the row to go anywhere. This is what I tried.
local rowTitle = display.newText( row, "Row " .. row.index .. tostring(messageToRender) , 0, 0, display.contentWidth, row.contentHeight \*0.5, 12 ) also local rowTitle = display.newText( row, "Row " .. row.index .. tostring(messageToRender) , 0, 0, row.contentWidth, 12 )
So I assume I have to tell it to be within the row’s width not the display width or is there a way to combine the two?
because it just shrinks everything when I do the second way above.
Well your width shouldn’t be greater than the width of the tableView. You probably should leave some padding too. It doesn’t make any sense for your text height to be greater than the row height, but again you probably should leave some vertical padding too.
If you’re just going to be loading up text blocks, I don’t think a tableView is what you want. TableViews are very specific use case. People are expected to interact with rows. You should probably consider a scrollView and just keep track of the last text you created and draw the next text at the last text’s. y + the last text’s height.
Rob
I don’t believe the text entries natively observe the groups/widgets into which they are inserted. You will most likely have to modify the width of the newText() object so that it reflects the bounds of your rows:
https://docs.coronalabs.com/api/library/display/newText.html#width-height-optional
Alex is right, you have to use display.newText() in multi-line mode (i.e. specify a width and optional height to try and fit the text into). But that said… The user experience for a tableView is to show many rows of limited information on the screen. The user interacts with the row to see the more in depth details on a screen dedicated to that entry.
Trying to fit too much information into a tableView row is not something your users are going to expect.
Rob
Thanks for the replys guys. I looked into it and tried making that change but I think I am doing it wrong. I need it to be multiple lines becuase I am using the rows as read only like Lifeline text based game. The user doesn’t click on the row to go anywhere. This is what I tried.
local rowTitle = display.newText( row, "Row " .. row.index .. tostring(messageToRender) , 0, 0, display.contentWidth, row.contentHeight \*0.5, 12 ) also local rowTitle = display.newText( row, "Row " .. row.index .. tostring(messageToRender) , 0, 0, row.contentWidth, 12 )
So I assume I have to tell it to be within the row’s width not the display width or is there a way to combine the two?
because it just shrinks everything when I do the second way above.
Well your width shouldn’t be greater than the width of the tableView. You probably should leave some padding too. It doesn’t make any sense for your text height to be greater than the row height, but again you probably should leave some vertical padding too.
If you’re just going to be loading up text blocks, I don’t think a tableView is what you want. TableViews are very specific use case. People are expected to interact with rows. You should probably consider a scrollView and just keep track of the last text you created and draw the next text at the last text’s. y + the last text’s height.
Rob