Is it possible to display text in a LL item/panel which can be scrolled?

Is it possible to display text in a LL item/panel which can be scrolled?

I want to create a clipboard viewer (not editor) which may contain text that takes up more space than the clipboard area. I don’t want to edit the text but want to be able to scroll it. What is the best way to achieve this?

]]>

12 Commentsto Is it possible to display text in a LL item/panel which can be scrolled?

  1. Anonymous says:

    < ![CDATA[

    Custom view scrollview with a TextView inside. I think theres a clipboard viewer script in the wiki btw.

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Jay M I saw the clipboard viewer on the wiki too, but it doesn’t seem to use scrollview. does anyone have some example code?



    assume the steps would be:


    – add item with customview


    – set script on customview resumed


    – script sets up scrollview and textview within scrollview?

    ]]>

  3. Anonymous says:

    < ![CDATA[

    The clipboard viewer script permits scrolling, if you don’t want to edit it you can disable editing from the edit text view.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    TrianguloY thank you! i was just working on this and managed to tweak it to what i am looking to do.



    is there a way to get a customview to use a custom font like in LL? or are the fonts limited to the android font family built into the system?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    It should be possible to use a external file, yes, but I never tried it. I’ll try to check it

    ]]>

  6. Anonymous says:

    < ![CDATA[

    thank you – here’s my script which i modified from yours. i’d like to scroll the EditText using a command, but can’t get edittext.scrollTo to work. any suggestions?



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


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



    var cntx=LL.getContext();


    var clipboard = cntx.getSystemService(cntx.CLIPBOARD_SERVICE);


    var cText=getCText();



    try{typeof item}catch(e){


    item.setVerticalGrab(true);


    var v=new EditText(cntx);


    v.setTextColor(0xffffffff);


    v.setBackgroundColor(Color.TRANSPARENT);


    v.setGravity(48);


    setVText(v,cText);


    return v;


    }



    var source = LL.getEvent().getSource();


    var it=LL.getEvent().getItem();


    var itv=it.getView();


    if (LL.getEvent().getData() == “edit”) {


    itv.setFocusable(true);


    itv.setFocusableInTouchMode(true);


    itv.setCursorVisible(true);



    else if (LL.getEvent().getData() >0) {


    itv.setTextSize(LL.getEvent().getData());


    } else {



    switch(source){


    case “I_RESUMED”:


    itv.setFocusable(false);


    itv.setCursorVisible(false);


    setVText(itv,cText);


    itv.setTextSize(20);


    break;



    }



    function setVText(v,t){


    if(t==null){


    v.setText(“clipboard empty”); 


    }else{


    v.setText(t);


    }




    function getCText(){


    if(!clipboard.hasPrimaryClip()) return null


    if(!clipboard.getPrimaryClipDescription().hasMimeType(“text/*”))return null;


    var t= clipboard.getPrimaryClip().getItemAt(0).getText();


    return t;


    ]]>

  7. Anonymous says:

    < ![CDATA[

    I believe scrollTo should work, but there is one case where it may not work. I am not sure about this, maybe I am wrong but I remember a similar issue: if you change the content of the edittext and call scrollTo immediately (in the same script), it won’t work because the view layout operation has not been performed yet and the view doesn’t know the area used by the text yet. You need to delay the call to scrollTo (or scrollBy) until the view measurement and layout are done.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    thanks Pierre Hébert . i will try to call the scrollTo from a different script than the one that sets up the EditText. What is the best way to do this? I tried using getItemByName and getItemById, both with no luck. since it may not be run from the customview itself, i am not sure if getEvent() would work?

    ]]>

  9. Anonymous says:

    < ![CDATA[

    You could just use setTimeout, or store the reference in the root javascript object maybe.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Pierre Hébert could you help point me in the right direction on how to get and use the reference? the customview (edittext) is inside a folder, and i tried getting the Id, getting the folder first then getting the item, getEvent(), can’t get any of them to work … thanks!

    ]]>

  11. Anonymous says:

    < ![CDATA[

    I mean, in order to add a short delay between the setText call and the scrollTo call, try with this first:


    edittext.setText(“lorem ipsum”);


    setTimeout(function() {


        edittext.scrollTo(0, 100);


    }, 50);


    A zero timeout may just be enough, the goal is to let the android framework execute measure/layout on edittext.



    Otherwise you can store a global the reference to edittext using this simple way:



    In script A:


    var v=new EditText(cntx);


    my_edittext = v;;



    In script B:


    my_edittext.scrollTo(x, y);



    Here the my_edittext is stored on the shared “Window” object which is the root one.



    You should be able to retrieve the custom view using CustomView.getView(). Then if you have the custom view item id, you should be able to retrieve it using LL.getItemId()

    ]]>

  12. Anonymous says:

    < ![CDATA[

    perfect … thanks Pierre Hébert !

    ]]>

Leave a Reply

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