Back

CheckBoxes

Create CheckBoxes using the CreateCheckBox method of the app object:

 chk = app.CreateCheckBox( text );

Use the SetOnTouch method of the CheckBox object to set the name of a function you want to be called when the CheckBox is touched. You can read the 'isChecked' parameter in your callback function to get the state of the CheckBox

Example

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

  chk = app.CreateCheckBox( "Enable Stuff" );
  chk.SetOnTouch( ShowState );
  lay.AddChild( chk );

  app.AddLayout( lay );
}

function ShowState( isChecked )
{
  app.ShowPopup( "Checked = " + isChecked, "Short" );
}
  Copy   Copy All    Run   

The following methods are avaiable on the CheckBox object:

 SetVisibility( visibility )
 GetVisibility()
 SetPadding( left, top, right, bottom )
 SetMargins( left, top, right, bottom )
 SetPosition( left, top, width, height )
 SetSize( width, height )
 GetWidth()
 GetHeight()
 SetOnTouch( callback )
 SetText( text )
 GetText()
 SetTextColor( colorCode )
 SetTextSize( size )
 SetChecked( checked )
 GetChecked()