Back

TextEdit

Create TextEdit objects using the CreateTextEdit method of the app object:

 edt = app.CreateTextEdit( text, width, height, options );

You can use the SetOnChange method of the TextEdit to set the name of a function you want to be called when a the text is changed.

Use the SetText and GetText functions to set and get the text in the TextEdit.

Example - Using OnChange

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

  edt = app.CreateTextEdit( "Edit me", 0.8, 0.3 );
  edt.SetOnChange( edt_OnChange );
  lay.AddChild( edt );

  txt = app.CreateText( "", 0.8, 0.3 );
  txt.SetMargins( 0, 0.02, 0, 0 );
  lay.AddChild( txt );

  app.AddLayout( lay );
}

function edt_OnChange()  
{
  txt.SetText( edt.GetText() );
}
  Copy   Copy All    Run   

You can change the look of a TextEdit using the SetBackColor and SetTextColor functions on the TextEdit object.

Example - Blue on White

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

  edt = app.CreateTextEdit( "Hello", 0.8, 0.4 );
  edt.SetTextColor( "#ff6666ff" );
  edt.SetBackColor( "#ffffffff" );
  lay.AddChild( edt );

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

You can also set a background image/pattern or background gradient for the List using the SetBackground and SetBackGradient functions. See Layouts for examples of how to use these functions.


The following methods are avaiable on the Text object:

 SetVisibility( visibility )
 GetVisibility()
 SetPadding( left, top, right, bottom )
 SetMargins( left, top, right, bottom )
 SetBackground( imageFile, options )
 SetBackColor( colorCode )
 SetBackGradient( color1, color2, color3 )
 SetBackGradientRadial( x, y, r, color1, color2, color3 )
 SetPosition( left, top, width, height )
 SetSize( width, height )
 GetWidth()
 GetHeight()
 SetText( text )
 SetHtml( html )
 GetText()
 SetTextColor( colorCode )
 SetTextSize( size )
 GetLineCount()
 GetMaxLines()
 GetLineTop( lineNum )
 GetLineStart( lineNum )
 SetCursorPos( pos )
 GetCursorPos()
 GetCursorLine()
 Undo()
 Redo()
 ClearHistory()