(Information and examples taken from the DroidScript documentation)
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.
app.GetLastButton();
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() ); }