DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


tips_tricks:seekbar_setontouchup

Differences

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

Link to this comparison view

tips_tricks:seekbar_setontouchup [2015/03/03 17:25] (current)
octazid created
Line 1: Line 1:
 +=====Seekbar SetOnTouchUp=====
 +(Sample Code posted by Steve Garman taken from the DroidScript Google Group)\\
  
 +Is something like that posible? There is no built-in way of doing this at present. But with this workaround you can simulate this.
 +
 +<code javascript>​
 +//Called when application is started.
 +function OnStart()
 +{
 +    //Create a layout with objects vertically centered.
 +    lay = app.CreateLayout( "​absolute",​ ""​ );    ​
 +
 +    //Create a text label and add it to layout.
 +    skb = app.CreateSeekBar( 0.8 );
 +    skb.SetPosition(0.1,​ 0.4, 0.8, 0.1);
 +    img = app.CreateImage(null,​ 0.8, 0.1);
 +    setTimeout(imgSetup,​0);​
 +    lay.AddChild( skb );
 +    lay.AddChild(img);​
 +    ​
 +    //Add layout to app.    ​
 +    app.AddLayout( lay );
 +}
 +function imgSetup()
 +{
 +    img.SetColor("#​00000000"​);​
 +    img.SetPosition(0.1,​ 0.4, 0.8, 0.1);
 +    img.SetOnTouch(imgOnTouch);​
 +}
 +
 +function imgOnTouch(ev)
 +{
 +    app.SimulateTouch(skb,​ ev.X, ev.Y, ev.action);
 +    if(ev.action == "​Up"​) skbOnTouchUp(ev);​
 +}
 +
 +function skbOnTouchUp(ev)
 +{
 +    app.ShowPopup("​Up\n"​+skb.GetValue());​
 +}
 +</​code>​
tips_tricks/seekbar_setontouchup.txt ยท Last modified: 2015/03/03 17:25 by octazid