viewvisibility.lzx
<canvas width="100%">
<dataset name="mydata">
<element>#1</element>
</dataset>
<class name="light">
<attribute name="bulbColor" type="color"/>
<attribute name="bulbVisibility" type="string"/>
<attribute name="bulbXpath" type="string"/>
<simplelayout axis="x" spacing="5"/>
<button onclick="parent.toggleVisibility()">Toggle Visibility</button>
<text name="display" font="Monaco, Courier, fixed"/>
<method name="updateDisplay">
display.format('data: %-4#w + visibility: %-11#w -> visible: %-7#w', bulb.data, bulb.visibility, bulb.visible);
</method>
<text name="bulb" width="20" height="20" bgcolor="${classroot.bulbColor}" visibility="${classroot.bulbVisibility}" datapath="${classroot.bulbXpath}" oninit="classroot.updateDisplay()" ondata="classroot.updateDisplay()"/>
<method name="toggleVisibility">
switch (bulb.visibility) {
case 'visible':
bulb.setAttribute('visibility', 'collapse');
break;
case 'collapse':
bulb.setAttribute('visibility', 'hidden');
break;
case 'hidden':
bulb.setAttribute('visibility', 'visible');
break;
}
updateDisplay();
</method>
</class>
<class name="demo" bgcolor="gray90">
<simplelayout axis="y" spacing="2"/>
<attribute name="lightXpath" type="string"/>
<light bulbColor="red" bulbVisibility="hidden" bulbXpath="${classroot.lightXpath}"/>
<light bulbColor="yellow" bulbVisibility="collapse" bulbXpath="${classroot.lightXpath}"/>
<light bulbColor="green" bulbVisibility="visible" bulbXpath="${classroot.lightXpath}"/>
</class>
<simplelayout axis="y" spacing="7"/>
<demo lightXpath="mydata:/element[1]/text()"/>
<demo lightXpath="mydata:/element[2]/text()"/>
<demo lightXpath="mydata:/element[3]/text()"/>
<attribute name="next" value="2
"/>
<button onclick="if (canvas.next < 4) {mydata.getPointer().addNode('element', '#' + canvas.next++)}">
Add Data
</button>
<button onclick="if (canvas.next > 1) {var p = mydata.getPointer(); p.setXPath('element[' + --canvas.next + ']'); p.deleteNode();}">
Remove Data
</button>
</canvas>
Cross References
Classes
Named Instances