DroidScript / Docs

DroidScript Documentation
Apache License 2.0
85 stars 30 forks source link

SimulateTouch example Javascript #230

Open Al4He6 opened 3 months ago

Al4He6 commented 3 months ago

https://github.com/DroidScript/Docs/blob/63145db940b0ace9ef88855f7e3a4ec9c6c4576c/files/markup/en/app/SimulateTouch.js#L22

Needs to simulate down and up to trigger InTouch function and animate runs repeatedly. This simulates one touch

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

btn = app.AddButton( lay,"Press Me", 0.3, 0.1 );
btn.SetOnTouch( btn_OnTouch );

app.AddLayout( lay );

app.SimulateTouch( btn, 0.5, 0.5, "down" );
app.SimulateTouch( btn, 0.5, 0.5, "up" );

}

function btn_OnTouch() { app.ShowPopup( "Button touched","long"); }