Back

CreateText

Text creates a Text object.

app.CreateText( text, width, height, options ) -> app object - Text

Example - Single line



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    txt = app.CreateText( "Hello" );
    txt.SetTextSize( 22 );
    lay.AddChild( txt );

    app.AddLayout( lay );
}
    Copy     Copy All       Run      

Example - Multi line



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    txt = app.CreateText( "Hello\nWorld", 0.8, 0.2, "Multiline" );
    txt.SetTextSize( 12 );
    txt.SetTextColor( "#ff6666ff" );
    txt.SetBackColor( "#ffffffff" );
    lay.AddChild( txt );

    app.AddLayout( lay );
}
    Copy     Copy All       Run      

Example - Ellipsize



function OnStart()
{
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

    txt = app.CreateText( "The quick brown fox jumps over the lazy dog", 0.75 );
    txt.SetTextSize( 28 );
    txt.SetEllipsize( "end" );
    lay.AddChild( txt );

    app.AddLayout( lay );
}
    Copy     Copy All       Run      

The following methods are avaiable on the Text object:

  Destroy()
  Explode()
  Focus()
  GetAbsHeight() -> number - integer
  GetAbsWidth() -> number - integer
  GetHeight( options ) -> number - fraction of screen height
  GetHtml() -> string - html
  GetLeft( options ) -> number - fraction of screen width
  GetLineCount() -> number - integer
  GetLineStart( line ) -> number - integer
  GetLineTop( line ) -> unknown
  GetMaxLines() -> number - integer
  GetPosition( options ) -> object - { left: fraction of parent width, top: fraction of parent height, right: fraction of parent width, bottom: fraction of parent height }
  GetText() -> string
  GetTextSize( mode ) -> number - integer
  GetTop( options ) -> number - fraction of screen height
  GetType() -> string - "Text"
  GetVisibility() -> string - "Show" or "Hide" or "Gone"
  GetWidth( options ) -> number - fraction of screen width
  Gone()
  Hide()
  IsEnabled() -> boolean
  IsOverlap( obj, depth ) -> boolean
  IsVisible() -> boolean
  Release()
  SetScale( x, y )
  SetText( text )
  Show()
  id -> string - "#id"

string
number - fraction of screen width
number - fraction of screen height
unknown
number
set color effects
?
destroys object
destroys object with explode animation and sound
?
get height in pixels
get width in pixels
get screen relative height
return text formatted with str_html tags
get distance to left parent border
GetLineCount
number - integer
return number of character where a given line starts
?
GetMaxLines
GetTextSize
get distance to upper parent border
GetVisibility
get screen relative width
Set visibility "Gone"
Set visibility "Hide"
IsEnabled
app object
return wether obj overlap with an other
IsVisible
append text with line break
?
string -
  hexadecimal: "#rrggbb", "#aarrggbb"
  colourName: "red", "green", ...
SetBackColor
SetBackColorRadial
string - path to file or folder ( "/absolute/..." or "relative/..." )
changes the background image
string - "Add" or "Multiply" or "?"
adjust color
?
boolean
en/disable object
change font style
string - html
allows using str_html tags for formatting
SetLog
move object from current position
function( self )
callen when object long pressed
function( event )
called when user touches object
function( event )
called when finger comes down
function( event )
called when finger was moved over screen
function( event )
called when finger leaves screen
set surrounding borders
SetPosition
number - factor
SetScale
change object size
SetText
SetTextColor
SetTextShadow
SetTextSize
SetTouchable
string - "Show" or "Hide" or "Gone"
change visibility mode
Set visibility "Show"
?
object id
{
    source: app object,
    action: string - "Down" or "Move" or "Up",
    count: number - integer,
    X: number - fraction of screen width,
    Y: number - fraction of screen height,
    x: list - [ x1, x2, x3 ],
    y: list - [ y1, y2, y3 ]
}