DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


built_in:get_last_toggle

Differences

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

Link to this comparison view

built_in:get_last_toggle [2015/03/04 16:29] (current)
octazid created
Line 1: Line 1:
 +=====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.
 +
 +<​code>​app.GetLastToggle();</​code>​
 +
 +----
 +
 +====Example====
 +
 +<code javascript>​
 +
 +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() );
 +}
 +
 +</​code>​
built_in/get_last_toggle.txt ยท Last modified: 2015/03/04 16:29 by octazid