If you want to set the visibility/transparency of an item staticly, there’s no need for scripting. Just long-tap, “Customize Item”, “More…”, “+” tab, change value of “Transparency”.
If you want to swipe or to tap an item to hide another you need to know the label of the item you want to hide. Say you want to hide/show an item named Silvia using swipe in the same container/desktop.
Set a swipe event to Run a script and copy this into the script editor:
var itemLabel = “Silvia”;
// getting item from container
var e = LL.getEvent().getContainer().getItemByLabel(itemLabel);
if (!e)
e = LL.getCurrentDesktop().getItemByLabel(itemLabel);
// toggle visibility
if ( e.isVisible() )
e.setVisibility(false);
else
e.setVisibility(true);
Now close the script editor and try it out.
If item Silvia is in a different desktop or container then you need to know the name or ID of the container, and replace the code after // getting item from container with something else.
< ![CDATA[
If you want to set the visibility/transparency of an item staticly, there’s no need for scripting. Just long-tap, “Customize Item”, “More…”, “+” tab, change value of “Transparency”.
]]>
< ![CDATA[
Just explain what is you are looking to obtain.
Is it as simple as swipe to hide/show? Something more complex?
]]>
< ![CDATA[
Swipe or tap to hide/show.
]]>
< ![CDATA[
If you want to swipe or to tap an item to hide another you need to know the label of the item you want to hide. Say you want to hide/show an item named Silvia using swipe in the same container/desktop.
Set a swipe event to Run a script and copy this into the script editor:
var itemLabel = “Silvia”;
// getting item from container
var e = LL.getEvent().getContainer().getItemByLabel(itemLabel);
if (!e)
e = LL.getCurrentDesktop().getItemByLabel(itemLabel);
// toggle visibility
if ( e.isVisible() )
e.setVisibility(false);
else
e.setVisibility(true);
Now close the script editor and try it out.
If item Silvia is in a different desktop or container then you need to know the name or ID of the container, and replace the code after // getting item from container with something else.
]]>
< ![CDATA[
I get a reference error itemName is not defined.
]]>
< ![CDATA[
Sorry, replace itemName with itemLabel
Updated my previous post to repair my mistake.
]]>
< ![CDATA[
Yay! Thank you!
]]>
< ![CDATA[
Ok, now what if I want to toggle show one while hiding another?
]]>
< ![CDATA[
var item1 = “Silvia”;
var item2 = “TBog”;
function _getItem(name)
{
var e = LL.getEvent().getContainer().getItemByLabel(name);
if (!e)
e = LL.getCurrentDesktop().getItemByLabel(name);
return e;
}
var e1 = _getItem(item1);
var e2 = _getItem(item2);
if ( e1.isVisible() )
{
e1.setVisibility(false);
e2.setVisibility(true);
}
else
{
e1.setVisibility(true);
e2.setVisibility(false);
}
]]>
< ![CDATA[
Thank you very very much!
]]>
< ![CDATA[
Ok, now since the update I’m having a problem with the second one. It comes back with cannot call method isvisible for null.?
]]>
< ![CDATA[
What type of item is item2? Has the name changed? I don’t see what Pierre Hébert could have changed.
]]>
< ![CDATA[
Lol, nm. I had one of my names wrong. I had blueapps and it should’ve been blueapps2. 😉
]]>