User Tools

Site Tools


built_in:text

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
built_in:text [2014/09/17 18:15]
stevegarman created
built_in:text [2015/09/12 07:48]
stevegarman Link to GetType
Line 1: Line 1:
 ====== Text control ====== ====== Text control ======
 +
 +//(Information and examples taken from the DroidScript documentation)//
 +
 +===== Description =====
 +Create Text objects using the **CreateText** method of the **[[app]]** object:
 +<code>txt = app.CreateText( text, width, height, options );</code>
 +You can use the **"Multiline"** option to allow multi-line text and the **"Left"** or **"Right"** options to align the text. The default is single line centered text.
 +
 +Use the **SetText** and **GetText** functions of the Text object to set and get it's text.
 +
 +==== Example - Single line ====
 +<code javascript>
 +function OnStart()
 +{
 +  lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
 +
 +  txt = app.CreateText( "Hello" );
 +  txt.SetTextSize( 22 );
 +  lay.AddChild( txt );
 +
 +  app.AddLayout( lay );
 +
 +</code>
 +You can change the look of a Text using the **SetBackColor** and **SetTextColor** functions on the Text object.
 +
 +==== Example - Multi line ====
 +<code javascript>
 +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 );
 +}
 +</code>
 +You can also set a background image/pattern or background gradient for the Text using the **SetBackground** and **SetBackGradient** functions. See **[[built_in:layouts|Layouts]]** for examples of how to use these functions.
  
 ===== Methods ===== ===== Methods =====
 +Some controls use the same methods.\\
 +For examples of the **[[same methods]]** look here.
 ^Method ^Description ^ ^Method ^Description ^
-|txt.GetHeight| | +|Text.Destroy() | | 
-|txt.GetLineCount| | +|Text.GetAbsHeight() | | 
-|txt.GetLineStart| | +|Text.GetAbsWidth() | | 
-|txt.GetLineTop| | +|Text.GetHeight() | | 
-|txt.GetMaxLines| | +|Text.GetLineCount() | | 
-|txt.Gettxt| | +|Text.GetLineStart( line ) | | 
-|txt.GetVisibility| | +|Text.GetLineTop( line ) | | 
-|txt.GetWidth| | +|Text.GetMaxLines() | | 
-|txt.Release| | +|Text.GetPosition() | | 
-|txt.SetBackColor| | +|Text.GetText() | | 
-|txt.SetBackGradient| | +|Text.GetTextSize( mode ) | | 
-|txt.SetBackGradientRadial| | +|[[built_in:gettype|Text.GetType()]] | | 
-|txt.SetBackground| | +|Text.GetVisibility() | | 
-|txt.SetHtml| | +|Text.GetWidth() | | 
-|txt.SetMargins| | +|Text.Release() | | 
-|txt.SetOnLongTouch| | +|Text.SetBackColor( color ) | | 
-|txt.SetOnTouch| | +|Text.SetBackGradient( color1,color2,color3,p4,p5,p6,p7 ) | | 
-|txt.SetOnTouchDown| | +|Text.SetBackGradientRadial( x,y,r,color1,color2,color3,p7 ) | | 
-|txt.SetOnTouchMove| | +|Text.SetBackground( imagefile,options ) | | 
-|txt.SetOnTouchUp| | +|Text.SetEllipsize( mode ) |Shorten long text with "..."  mode="Start","Middle" or "End"
-|txt.SetPadding| | +|Text.SetFontFile( file ) | | 
-|txt.SetPosition| | +|Text.SetHtml( html ) | | 
-|txt.SetSize| | +|Text.SetMargins( left,top,right,bottom ) | | 
-|txt.Settxt| | +|Text.SetOnLongTouch( callback ) | | 
-|txt.SettxtColor| | +|Text.SetOnTouch( callback ) | | 
-|txt.SettxtSize| | +|Text.SetOnTouchDown( callback ) | | 
-|txt.SetTouchable| | +|Text.SetOnTouchMove( callback ) | | 
-|txt.SetVisibility! !+|Text.SetOnTouchUp( callback ) | | 
 +|Text.SetPadding( left,top,right,bottom ) | | 
 +|Text.SetPosition( left,top,width,height ) | | 
 +|Text.SetScale( x,y ) | | 
 +|Text.SetSize( width,height ) | | 
 +|Text.SetText( text ) | | 
 +|Text.SetTextColor( color ) | | 
 +|Text.SetTextShadow( radius,dx,dy,color ) | | 
 +|Text.SetTextSize( size,mode ) | | 
 +|Text.SetTouchable( touchable ) | | 
 +|Text.SetVisibility( HideShow ) | | 
 + 
 +===== Options ===== 
 + 
 +^Option ^Description ^ 
 +|Bold| Write bold Text | 
 +|FontAwesome|Use this to display Icons \\ from this inbuilt font| 
 +|Html| | 
 +|Left| | 
 +|Multiline| | 
 +|Right| | 
built_in/text.txt · Last modified: 2019/06/22 01:01 (external edit)