Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Example for FontBase:LayoutText — Gideros Forum

Example for FontBase:LayoutText

I've spent a while trying to work out how to split long texts into multiple textfields.

It didn't help that I couldn't find an example. Here's what I've got at the moment:

app @ application
local width = app:getContentWidth()

local rawText = "This is a long bit of text to bottom out setLayout once and for all. Some more words to make sure that this is plenty of text to force the function to split it out into multiple boxes."
local myFont = Font.new("arial-12.txt", "arial-12.png")
local fontTable = myFont:layoutText(rawText, width-20, 320, 0, 0, 0, 4, " ")
local testBox

for i, v in ipairs(fontTable.parts) do
    testBox = TextField.new(myFont, v.text, "", v)
    testBox:setPosition(10, i*20)
    stage:addChild(testBox)
end

Sorry about the mess I've made putting the listing on this post.

If it helps, I can expand on my digging through the code.

Likes: hgy29

--
Get your CIX on route 109.123.97.120
+1 -1 (+1 / -0 )Share on Facebook

Comments

  • hgy29hgy29 Maintainer
    Hi @elves, sorry, I always hate when someone asks 'how do I do something' on a forum and people answer 'don't do that' or 'why would you want to do that', but this time I wonder: why don't you use a single TextField ?
  • The reason is to avoid creation of TextFields with static content.

    The text in my app is variable and likely more than a screen's worth on a phone. I would rather not use scrolling.

    I wasn't asking. I was saying i'd found a way to use FontBase:LayoutText.

    Perhaps I should have been more explicit:

    Are there any examples of how to use the result of FontBase:LayoutText?
    --
    Get your CIX on route 109.123.97.120
Sign In or Register to comment.