Difference between revisions of "TextField:setLayout"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 17: | Line 17: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
TextField:setLayout(layout) | TextField:setLayout(layout) | ||
− | </ | + | </syntaxhighlight> |
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
Line 40: | Line 40: | ||
textfield:setPosition(50, 50) | textfield:setPosition(50, 50) | ||
stage:addChild(textfield) | stage:addChild(textfield) | ||
− | </ | + | </syntaxhighlight> |
{{TextField}} | {{TextField}} |
Revision as of 14:33, 13 July 2023
Available since: Gideros 2017.10
Class: TextField
Description
Change the layout parameters for this TextField Layout parameters can contain the following fields:
- w,h: Width/height of the area to layout the text in
- flags: A or combination of FontBase.TLF_xxx constants instructing how to layout the text
- letterSpacing: The space to add between each letter of the text
- lineSpacing: The space to add between each line of the text
- tabSpace: The size of a tab in space characters increment, default to 4 if unspecified
- breakChar: A string that will be inserted to indicated broken words
- alignX,alignY: relative alignment of the text inside its cell. Defaults to 0.5,0.5. Since 2020.7
TextField:setLayout(layout)
Parameters
layout: (table) Layout parameters
Example
-- a string variable
local mystring = "Some very long text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor."
-- the text field with default system font
local textfield = TextField.new(nil, mystring)
-- we set the string that will be used as sample for determining text line height
textfield:setSample(mystring)
-- then we set the layout: width, height, line spacing and justify center
textfield:setLayout( {w=200, h=100, lineSpacing=7, flags=FontBase.TLF_CENTER} )
-- finally, we set the text position and add it to stage
textfield:setPosition(50, 50)
stage:addChild(textfield)
- TextField
- TextField.new
- TextField:getLayout
- TextField:getLetterSpacing
- TextField:getLineHeight
- TextField:getPointFromTextPosition
- TextField:getSample
- TextField:getText
- TextField:getTextColor
- TextField:getTextPositionFromPoint
- TextField:setFont
- TextField:setLayout
- TextField:setLetterSpacing
- TextField:setSample
- TextField:setText
- TextField:setTextColor