Table of Contents

GetLastToggle

(Information and examples taken from the DroidScript documentation)

Description

The GetLastToggle method returns the last toggle button that was touched by the user. This can be useful when you want to use a single callback function for multiple toggle buttons.

app.GetLastToggle();

Example

function OnStart()
{
  lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
 
  btn1 = app.CreateToggle( "Button 1" );
  btn1.SetOnTouch( HandleButton );
  lay.AddChild( btn1 );
 
  btn2 = app.CreateToggle( "Button 2" );
  btn2.SetOnTouch( HandleButton );
  lay.AddChild( btn2 );
 
  app.AddLayout( lay );
}
 
function HandleButton()
{
  var btn = app.GetLastToggle();
  app.ShowPopup( btn.GetText() );
}