Reference for the premium feature obj.Method(name, types, p1)

214 views
Skip to first unread message

Bubu Daba

unread,
Mar 2, 2021, 5:45:14 AM3/2/21
to DroidScript
Where to get all the available methods for every droidscript object?

Dave

unread,
Mar 2, 2021, 8:16:01 AM3/2/21
to DroidScript
This advanced feature allows you to make calls to the underlying Android APIs which can be useful if you find a feature is missing from DS.   You need to look in the Android docs for that information.

For example this is the docs for an Android View (all DS controls are made from Android Views)


Here is an example of setting the view gravity if a text control using this method:-

txt.Method( "setGravity", "int", 16 /*CENTER_VERTICAL*/ )

Here is the relevant area of the docs:- https://developer.android.com/reference/android/view/Gravity


Here is an example of creating a vertical SeekBar by using the Java setRotation method via reflection:-

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

    skb = app.CreateSeekBar( 0.4 );
    skb.Method( "setRotation", "float", 270)
    skb.SetRange( 1.0 );
    skb.SetValue( 0.5 );
    skb.SetOnTouch( skb_OnTouch );
    lay.AddChild( skb );

    app.AddLayout( lay );
}

function skb_OnTouch( value )
{
    app.ShowPopup( "Value = " + value );
}


You can pass up to 4 parameters to .Method() , you need to pass a comma separated list of parameter types as the second parameter ( int, float, boolean, string )

For example:-

txt.Method( "someAndroidMethod", "int,string", 16, "hello" )
Message has been deleted

Alan Hendry

unread,
Feb 19, 2022, 9:18:30 AM2/19/22
to DroidScript
HI,
Following a post about Card (rounded corners) I've been looking at Method.
I tried roundCorner, RoundedCorner, setRoundedCorner but they all give me messages like
    WARNING: Obj.Method() failed! (Method roundedCorner not found)
    lay2 = app.AddLayout(lay,"linear")
    lay2.SetSize(0.5,0.5)
    lay2.Method("roundedCorner","int,int,int,int",0,5,5,5)
(parameters are integers 0/1/2/3 for which corner, radius, centerX, cemterY)
Regards, ah

Ignas Bukys

unread,
Feb 19, 2022, 5:44:23 PM2/19/22
to DroidScript
wild guess: maybe your capital letters are not right? Try  RoundedCorner

Alan Hendry

unread,
Feb 20, 2022, 1:13:30 PM2/20/22
to DroidScript
HI,

Rethinking slightly I tried a Card Layout (which as rounded corners, and method SetCornerRadius)

setGravity and setRotation work, so I modeled it on them.
roundedcorner, roundedCorner, Roundedcorner, RoundedCorner all fail
setroundedcorner, setroundedCorner, setRoundedcorner, setRoundedCorner also fail
Setroundedcorner, SetroundedCorner, SetRoundedcorner, SetRoundedCorner are also bad
setCornerRadius and SetCornerRadius no good either

Regards, ah
Reply all
Reply to author
Forward
0 new messages