Testing new screen API getitembyid() to retrieve a folder within a panel without traversing the complete hierarchy.
Testing new screen API getitembyid() to retrieve a folder within a panel without traversing the complete hierarchy. Doesn’t work as expected.
//Get the id of the folder
id=getEventScreen().getCurrentDesktop().getItemByName(“panel”).getContainer().getItemByName(“folder”).getId()
//Doesn’t open the folder by accessing the folder directly without traversing the hierarchy (which would be elegent)
getEventScreen().getCurrentDesktop().getItemById(id).open()
//Does open the folder. but is tedious and hard-coded hierarchy which I would want to avoid
getEventScreen().getCurrentDesktop().getItemByName(“panel”).getContainer().getItemByName(“folder”).open()
]]>« 14a7/14a4 – LL crash – http://pastebin.com/2b85ryuB (Previous Post)
(Next Post) My Lockscreen (self made Kwgt widget) on LL. »
< ![CDATA[
I confirm it should work with the “short” expression, I’ll look at this.
]]>
< ![CDATA[
I just noticed something wrong in:
getEventScreen().getCurrentDesktop().getItemById(id).open()
getItemById will return null, because it will only looks in the container
Use getEventScreen().getItemById(id).open() and it will work as expected because this version of getItemById returns the first item found in the container hierarchy (see also getAllItemsById)
]]>
< ![CDATA[
That seems to work indeed. Cheers.
So using getCurrentDesktop was narrowing the result from the beginning.
]]>