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();
]]>« Hi. (Previous Post)
(Next Post) This might be suggested before, or there might already be a known way of doing it, but is there a way to get all the… »
< ![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 (*)
]]>
< ![CDATA[
getItems return a not-javascript object. http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/Array.html
Use pnl.getItems().getAt(0)
]]>
< ![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); }
]]>