[Not work?!] TextEdit focus/transform

67 views
Skip to first unread message

Gloglas´s Studio

unread,
Dec 26, 2016, 3:25:16 PM12/26/16
to DroidScript
Hi guys,
  I am making code editor but i can´t transform textedit when keyboard appear.
  I tried check every 100 miliseconds if is keyboard open and then resize txtedit but there was bug. When you clicked on bottom half of txtedit it made blank space between keyboard and txtedit.
  I also tried use Focus but i can´t get it working.
Please help.

var chg = false;
var clicked = false;
//Called when application is started.
function OnStart() {
   
//setup///////
    app
.SetOrientation("Portrait");
    app
.EnableBackKey(false);
   
////////////////////////////
    appl
= app.CreateLayout("Linear", "VCenter,FillXY");

    scroll
= app.CreateScroller(1.0, 1.0);

    appl
.AddChild(scroll);

    app
.AddLayout(appl);

    lay
= app.CreateLayout("Linear", "VCenter,FillXY");
    scroll
.AddChild(lay);
    lay
.SetBackColor("#222222");




   
///app
   
var code = "var text = 'TEST';\n" +
       
"g = Graphics.createArrayBuffer(5,5,1);\n" +
       
"g.flip = function(){show(this.buffer);};\n" +
       
"var x = 0;\n" +
       
"\n" +
       
"function draw()\n" +
       
"{\n" +
       
"if( x++ > text.length*5 ) x=0;\n" +
       
"g.clear();\n" +
       
"g.drawString( text, 5-x);\n" +
       
"g.flip();\n" +
       
"}\n" +
       
"\n" +
       
"setInterval(draw,150);\n";
    layup
= app.CreateLayout("Linear", "Horizontal,FillX");


    layup
.SetBackGradient("#ffffff", "#a7a7a7");

    lay
.SetBackColor("#a7a7a7");
    bl
= app.CreateButton("[fa-bluetooth]", -1, 0.12, "FontAwesome,Custom");
    bl
.SetStyle("#0000ff", "#0000aa", 10);

    bl
.SetTextSize(32);
    bl
.SetTextShadow(2, 0, 1, "#880000");
    layup
.AddChild(bl);

    btl
= app.CreateButton("[fa-bug]", -1, 0.12, "FontAwesome,Custom");
    btl
.SetStyle("#0000ff", "#0000aa", 10);

    btl
.SetTextSize(32);
    btl
.SetTextShadow(2, 0, 1, "#880000");
    layup
.AddChild(btl);


    bvl
= app.CreateButton("[fa-upload]", -1, 0.12, "FontAwesome,Custom");
    bvl
.SetStyle("#0000ff", "#0000aa", 10);

    bvl
.SetTextSize(32);
    bvl
.SetTextShadow(2, 0, 1, "#880000");
    layup
.AddChild(bvl);


    bsl
= app.CreateButton("[fa-eraser]", -1, 0.12, "FontAwesome,Custom");
    bsl
.SetStyle("#0000ff", "#0000aa", 10);

    bsl
.SetTextSize(32);
    bsl
.SetTextShadow(2, 0, 1, "#880000");
    layup
.AddChild(bsl);

    bl
= app.CreateButton("[fa-download]", -1, 0.12, "FontAwesome,Custom");
    bl
.SetStyle("#0000ff", "#0000aa", 10);

    bl
.SetTextSize(32);
    bl
.SetTextShadow(2, 0, 1, "#880000");
    layup
.AddChild(bl);



    lay
.AddChild(layup);

    layab
= app.CreateLayout("Absolute", "VCenter");
    lay
.AddChild(layab);

    txt
= app.CreateTextEdit(code, 0.98, 0.88, "MultiLine");
    txt
.SetBackColor("#e5e5e5");
    txt
.SetTextColor("Black");

    txt
.Focus();
    app
.ShowKeyboard(txt);
    layab
.AddChild(txt);

   
//(my notes) make layout{ and put on scroller(, then make lay{ {and put lay with buttons} and make {another lay with txtedit} })}

}


Steve Garman

unread,
Dec 28, 2016, 1:24:02 PM12/28/16
to DroidScript
//Perhaps you can use something based on this.


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

txt = app.CreateTextEdit("My Code", 0.98, 0.88);
txt.SetTextSize( 32 );
lay.AddChild( txt );
app.SetOnShowKeyboard( keybd );

app.AddLayout( lay );
txt.Focus();
app.ShowKeyboard( txt );
}

function keybd(shown)
{
var width = app.GetScreenWidth( )*0.98
var height = app.GetScreenHeight()*0.88
height -= app.GetKeyboardHeight();
txt.SetSize( width,height,"px");
}

Gloglas´s Studio

unread,
Dec 28, 2016, 1:57:55 PM12/28/16
to DroidScript
Oh thank you so much!
It won´t work sometimes when you have longer code but i will play with that.

Reply all
Reply to author
Forward
0 new messages