TextField:setLayout: Difference between revisions
From GiderosMobile
No edit summary |
→Description: added 1 example |
||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
<languages /> | <languages /> | ||
'''<translate>Available since</translate>:''' Gideros 2017.10<br/> | |||
'''<translate>Class</translate>:''' [[Special:MyLanguage/TextField|TextField]]<br/> | '''<translate>Available since</translate>:''' Gideros 2017.10 | ||
<br/> | |||
'''<translate>Class</translate>:''' [[Special:MyLanguage/TextField|TextField]] | |||
<br/> | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
<translate>Change the layout parameters for this TextField | <translate> | ||
Change the layout parameters for this TextField | |||
Layout parameters can contain the following fields: | Layout parameters can contain the following fields: | ||
* w,h: Width/height of the area to layout the text in | |||
* flags: A or combination of [[Special:MyLanguage/FontBase|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 the will be inserted to indicated broken words</translate> | |||
<br/> | |||
<source lang="lua"> | <source lang="lua"> | ||
TextField:setLayout(layout) | TextField:setLayout(layout) | ||
</source> | </source> | ||
<br/> | |||
'''Example''' | |||
<br/> | |||
<source lang="lua"> | |||
-- we initialize a text field | |||
local textfield = TextField.new(nil, "Some very long text with default system font. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.") | |||
-- 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) | |||
</source> | |||
<br/> | |||
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
'''layout''': (table) <translate>Layout parameters</translate> <br/> | '''layout''': (table) <translate>Layout parameters</translate> <br/> | ||
<br/> | |||
Revision as of 00:17, 28 May 2019
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 the will be inserted to indicated broken words
TextField:setLayout(layout)
Example
-- we initialize a text field
local textfield = TextField.new(nil, "Some very long text with default system font. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.")
-- 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)
Parameters
layout: (table) Layout parameters