I found that getItems() return the list of items from a container in a comma separated format.

I found that getItems() return the list of items from a container in a comma separated format.

I used below trying to get the list in an array, but all comes in items[0] as one item.

It would be nice to have an option to get all items’ names in an array.

var e=LL.getEvent();

var c=LL.getCurrentDesktop();

var pnl = c.getItemByName(‘pnlPersonal’).getContainer();

var items = new Array (pnl.getItems());

Android.makeNewToast(items[0], true).show();

]]>

3 Commentsto I found that getItems() return the list of items from a container in a comma separated format.

  1. Anonymous says:

    < ![CDATA[

    No.


    getItems() return a Lightning array (http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/Array.html).



    new Array(a,b,…) in JavaScript is not recommended to be used. [a,b,…] instead is the right way to do.


    When you do new Array(pnl.getItems()); you are creating an array with only one item, the Lightning array converted to a string, which is, as you saw, the shortcut names separated by comas.





    So, use the functions from the Lightning array:


    array.getAt(0) instead of array[0]


    array.getLength() instead of array.length (*)

    ]]>

  2. Anonymous says:

    < ![CDATA[

    That’s cool. This has helped me a lot. I’m going to use this for items rearrangement 😁



    var e=LL.getEvent();


    var c=LL.getCurrentDesktop();


    var pnl = c.getItemByName(‘pnlPersonal’).getContainer();


    var items = pnl.getItems();


    var m = pnl.getItems().getLength();



    for (i = 0; i < m; i++) {


    var item = items.getAt(i);


    item.setPosition(0, i); }

    ]]>

Leave a Reply

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