This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sample_code:droidscript_console [2016/08/28 20:38] titus created |
sample_code:droidscript_console [2016/10/31 05:41] (current) |
||
---|---|---|---|
Line 2: | Line 2: | ||
Execute your droidscript commands directly from this app. | Execute your droidscript commands directly from this app. | ||
+ | \\ | ||
+ | [[http:// | ||
- | <code JavaScript> | + | <code JavaScript |
+ | //Code By Titus | ||
//Called when application is started. | //Called when application is started. | ||
function OnStart() | function OnStart() | ||
{ | { | ||
- | //Create a layout with objects vertically centered. | + | app.SetOrientation(" |
- | lay = app.CreateLayout( " | + | app.EnableBackKey(false ); |
- | + | | |
- | //Create a text label and add it to layout. | + | lay = app.CreateLayout(" |
- | txt = app.CreateText( " | + | |
- | txt.SetTextSize( | + | //Create a text label and add it to layout. |
- | lay.AddChild( txt ); | + | txt = app.CreateText(" |
- | //Create Text Edit | + | txt.SetBackGradient("# |
- | edt = app.CreateTextEdit(" | + | txt.SetTextColor("# |
- | edt.SetBackColor( "# | + | txt.SetTextSize(23); |
- | edt.Focus(); | + | lay.AddChild(txt); |
- | edt.SetTextSize(13 ); | + | //Create Text Edit |
- | edt.SetOnEnter( clc ); | + | edt = app.CreateTextEdit(" |
- | lay.AddChild(edt); | + | edt.SetBackColor("# |
- | //Add layout to app. | + | edt.Focus(); |
- | app.AddLayout( lay ); | + | edt.SetTextSize(13); |
+ | edt.SetOnEnter(clc); | ||
+ | lay.AddChild(edt); | ||
+ | //Add layout to app. | ||
+ | app.AddLayout(lay); | ||
} | } | ||
- | function clc(){ | + | function clc() |
- | var t = edt.GetText() | + | { |
- | var p = edt.GetCursorPos();; | + | var t = edt.GetText() |
- | try{ | + | var p = edt.GetCursorPos();; |
- | edt.SetText(t+" | + | try |
- | edt.SetCursorPos(t.length ); | + | |
- | } | + | edt.SetText(t + " |
- | }catch(e){ | + | edt.SetCursorPos(edt.GetText().length); |
- | edt.SetText(t+" | + | |
- | edt.SetCursorPos(t.length ); | + | |
- | } | + | |
- | } | + | catch (e) |
+ | { | ||
+ | edt.SetText(t + " | ||
+ | edt.SetCursorPos(edt.GetText().length); | ||
- | function | + | } |
- | return | + | var tt = edt.GetText() |
- | ('return | + | tt = tt.replace(/ |
+ | | ||
+ | return | ||
+ | }) | ||
+ | tt = tt.replace(/ | ||
+ | { | ||
+ | | ||
+ | }) | ||
+ | tt = tt.replace(/ | ||
+ | { | ||
+ | return v.fontcolor("# | ||
+ | }) | ||
+ | tt = tt.replace(/ | ||
+ | { | ||
+ | return v.fontcolor("# | ||
+ | }) | ||
+ | tt = tt.replace(/ | ||
+ | edt.SetHtml(tt); | ||
} | } | ||
//Get properties and methods | //Get properties and methods | ||
- | function prop(objectname){ | + | function prop(objectname) |
- | this.s ="" | + | { |
- | this.a =0 | + | |
- | for(x in objectname){ | + | |
- | | + | for (x in objectname) |
- | this.s+=a+" " | + | |
- | | + | |
- | | + | s += a + " " + x + " |
- | | + | } |
+ | return s | ||
+ | } | ||
+ | var cnt=0 | ||
+ | function OnBack(){ | ||
+ | setTimeout(function(){cnt=0}, | ||
+ | if(cnt==1) app.Exit(); | ||
+ | else app.ShowPopup(" | ||
+ | cnt++ | ||
+ | } | ||
</ | </ | ||
+ | |||
+ | [[: |