Text Edit objects using the CreateTextEdit method of the Support object:
sup.CreateTextEdit( text, width, height, options );
options: Floating, SingleLine, Number, Phone, Password
Example - Simple
app.LoadPlugin( "Support" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
lay.SetBackColor( "#FAFAFA" );
sup = app.CreateSupport();
edt = sup.CreateTextEdit( "Hi, I am text edit.", 0.5 );
lay.AddChild( edt );
app.AddLayout( lay );
}
options: Floating
Example - Floating Label
app.LoadPlugin( "Support" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
sup = app.CreateSupport();
edt = sup.CreateTextEdit( "", 0.5, null, "floating" );
edt.SetHint( "My name is" ); // Float label.
edt.SetColor( "#FAFAFA" );
lay.AddChild( edt );
app.AddLayout( lay );
}
edt.SetMaxSize( size )
Example - Character Limit
app.LoadPlugin( "Support" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
sup = app.CreateSupport();
edt = sup.CreateTextEdit( "Write more...", 0.5, null, "floating" );
edt.SetColor( color.BLUE );
edt.SetMaxSize( 10 );
lay.AddChild( edt );
app.AddLayout( lay );
}
edt.SetOnChange( callback )
Example - On Change
app.LoadPlugin( "Support" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
sup = app.CreateSupport();
edt = sup.CreateTextEdit( "Write more...", 0.5, null, "floating" );
edt.SetColor( color.BLUE );
edt.SetMaxSize( 10 );
edt.SetOnChange( edt_OnChange );
lay.AddChild( edt );
app.AddLayout( lay );
}
function edt_OnChange( txt, len )
{
if( len > 10 ) edt.SetText( txt.slice(0,10) );
}
The following methods are available on the Text Edit object:
GetType()
GetText()
SetText( text )
SetTextColor( color )
SetTextSize( size )
SetMaxSize( size )
SetError( text )
SetErrorColor( color )
SetHint( text )
SetColor( color )
Other Methods:
Show Other Methods
Material Design EditText library, licensed under the Apache 2.0 License. go github page