Back

GetObjects

JS Py
Hello World

Returns a map of DroidScript control objects with their id as key.

app.GetObjects() → List: [ id: control ]

Example - Show Types of all Objects

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

    img = app.CreateImage( "/Sys/Img/Hello.png", 0.2, -1 );
    lay.AddChild( img );

    btn = app.CreateButton( "Get Objects", 0.3, 0.1 );
    btn.SetMargins( 0, 0.05, 0, 0 );
    btn.SetOnTouch( btn_OnTouch );
    lay.AddChild( btn );

    app.AddLayout( lay );
}

function btn_OnTouch()
{
    var objs = app.GetObjects();

    var lst = [];
    for(var i in objs)
        lst.push( i + ": " + objs[i].GetType() );

    app.Alert( lst.join( "\n" ));
}
from native import app

def OnStart():
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )

    img = app.CreateImage( "/Sys/Img/Hello.png", 0.2, -1 )
    lay.AddChild( img )

    btn = app.CreateButton( "Get Objects", 0.3, 0.1 )
    btn.SetMargins( 0, 0.05, 0, 0 )
    btn.SetOnTouch( btn_OnTouch )
    lay.AddChild( btn )

    app.AddLayout( lay )

def btn_OnTouch():
    objs = app.GetObjects()

    lst = []
    for i in objs:
        lst.append( i + ": " + objs[i].GetType() )

    app.Alert( "\n".join(lst) )
Copy All       Run      
app object
String: object id “#id”