DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


built_in:get_last_button

Differences

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

Link to this comparison view

built_in:get_last_button [2015/03/04 16:27] (current)
octazid created
Line 1: Line 1:
 +=====GetLastButton=====
 +
 +//​(Information and examples taken from the DroidScript documentation)//​
 +
 +====Description====
 +
 +The **GetLastButton** method returns the last button control that was touched by the user. This can be useful when you want to use a single callback function for multiple buttons.
 +
 +<​code>​ app.GetLastButton();</​code>​
 +
 +----
 +
 +====Example====
 +
 +<code javascript>​
 +
 +function OnStart()
 +{
 +  lay = app.CreateLayout( "​Linear",​ "​VCenter,​FillXY"​ );
 +
 +  btn1 = app.CreateButton( "​Button 1" );
 +  btn1.SetOnTouch( HandleButton );
 +  lay.AddChild( btn1 );
 +
 +  btn2 = app.CreateButton( "​Button 2" );
 +  btn2.SetOnTouch( HandleButton );
 +  lay.AddChild( btn2 );
 +
 +  app.AddLayout( lay );
 +}
 +
 +function HandleButton()
 +{
 +  var btn = app.GetLastButton();​
 +  app.ShowPopup( btn.GetText() );
 +}
 +
 +</​code>​
  
built_in/get_last_button.txt ยท Last modified: 2015/03/04 16:27 by octazid