This is a script made for scripters.

This is a script made for scripters.

It is useless for the rest of users, sorry.

So, if you are going to use this script, you should know how scripts works. Seeing the video will tell you all you need. (And also, if you improve it to your needs, share it here 🙂

Basic instructions:

Run the script from a container: adds the editor

Run the script from the editor item: change the edited script

Internally:

When it is run from the creation script, it creates the custom view

When it is run from the resumed event, it updates it’s text

Any change you make in the editor will be immediately changed in the script.

Keep a copy of the original script, just in case 🙂

Oh, and also you may want to place the editor at the top of the desktop, otherwise the keyboard will shift the whole desktop up (go to another app/activity, and then go back to fix it)

]]>

4 Commentsto This is a script made for scripters.

  1. Anonymous says:

    < ![CDATA[

    var textColor=0xffffffff;





    var tag=”dynamiceditor”;





    //classes


    LL.bindClass(“android.widget.EditText”);


    LL.bindClass(“android.text.TextWatcher”);


    LL.bindClass(“android.app.AlertDialog.Builder”);


    LL.bindClass(“android.app.AlertDialog”);


    LL.bindClass(“android.content.DialogInterface.OnClickListener”);


    LL.bindClass(“android.content.DialogInterface”);





    //vars


    var cntx=LL.getContext();


    var it;


    var v;


    var e;



    //to detect when the script is run from the creation script


    try{typeof item}catch(e){


    return returnview();


    }




    //from event


    e=LL.getEvent();


    var source=e.getSource();



    if(source==”MENU_APP”){


    addview();


    return


    }



    it=e.getItem();


    v=it.getView();




    if(source==”MENU_ITEM”)askscript();


    if(source==”I_RESUMED”)updateview();












    //checks if there is a saved script


    function checkscript(){


    var name=it.getTag(tag);



    if(name==null||LL.getScriptByName(name)==null){


    if(e!=null)Android.makeNewToast(“Script not set or not found. Please run the script from the view”,false).show();


    return false;


    }


    return true;


    }





    //prompts a list of the script to choose from


    function askscript(){



    var list=LL.getAllScriptMatching(Script.FLAG_ALL);


    var scripts=[];


    for(var t=0;t



    var builder = new AlertDialog.Builder(cntx);


    builder.setTitle(“Choose a script”);


    builder.setItems(scripts, new DialogInterface.OnClickListener() {onClick: function(dialog,item) {


    dialog.dismiss();


    it.setTag(tag,scripts[item]);


    updateview();


    }


    });


    builder.setNegativeButton(“Close”,null)


    builder.show();




    }





    function updatescript(){


    //replace the script text with the view text


    if(!checkscript())return;


    LL.getScriptByName(it.getTag(tag)).setText(v.getText());



    }






    function updateview(){


    //replace the view text with the script text


    if(!checkscript())return;



    v.setText(LL.getScriptByName(it.getTag(tag)).getText());



    }





    function returnview(){


    //returns the view


    it=item;



    item.setVerticalGrab(true);


    v=new EditText(cntx);


    v.setTextColor(textColor);


    v.setGravity(80);//BOTTOM



    v.setText(“run the script from this view”);



    v.addTextChangedListener(new TextWatcher({afterTextChanged:function(s){updatescript()},


    beforeTextChanged:function(s, start,count,after){},


    onTextChanged:function(s,start,before,count){}


    }));



    updateview();



    return v;


    }






    function addview(){


    //adds directly a custom view


    it=e.getContainer().addCustomView(e.getTouchX(),e.getTouchY());


    var thisid=””+LL.getCurrentScript().getId();


    var prop=it.getProperties().edit()


    prop.setString(“v.onCreate”,thisid)


    prop.setEventHandler(“i.resumed”,EventHandler.RUN_SCRIPT,thisid)


    prop.getBox(“i.box”).setColor(“c”, “s”, 0);


    prop.commit();




    v=it.getView();


    askscript();



    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Very nice!

    ]]>

  3. Anonymous says:

    < ![CDATA[

    this is exactly something i wanted. no more continuously opening the script editor.


    Big Thanks!

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Genial

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *