tooltip.lzx
<library>
<include href="tooltipview.lzx"/>
<class name="tooltip" extends="node" initstage="late">
<attribute name="text" type="text" style="content"/>
<method name="update"/>
<attribute name="yoffset" value="25
"/>
<attribute name="tipalign" value="left
" type="string"/>
<attribute name="tipvalign" value="default
" type="string"/>
<handler name="onmouseover" args="ignore" reference="this.parent">
this.update();
if (this.text && (this.text != "")) {
canvas.tooltipview.setAttribute('tooltip', this);
}
</handler>
<doc>
<tag name="shortdesc"><text>A floating "tooltip" for a view.</text></tag>
<text>
<p>
The <classname>tooltip</classname> allows you to show a floating "tooltip" on any
view. To use it you make it a child of a view. The parent view has
to be clickable for the tooltip to work. Setting clickable to false
will disable the tooltip.
</p>
<example title="Tooltip">
<canvas height="60" layout="axis:y; spacing: 10">
<text>Mouse over the button to see the tip</text>
<button text="Button, button">
<tooltip>Click or mouse out to hide tip</tooltip>
</button>
</canvas>
</example>
<p>
You can subclass <classname>tooltip</classname> and override
the <code>update</code> method to create dynamic tooltips
</p>
<example class="program" title="Dynamic Tooltip">
<canvas height="180">
<class name="timetip" extends="tooltip" with="formatter">
<attribute name="formats" value="{us: '%2$d/%3$d/%1$d %4$02d:%02d:%02d', eu: '%1$4d-%2$02d-%3$02d %4$02d:%02d:%02d'}" />
<method name="update">
var now = new Date;
this.setAttribute('text',
this.formatToString(
this.formats[locale.text],
now.getFullYear(),
now.getMonth(),
now.getDay(),
now.getHours(),
now.getMinutes(),
now.getSeconds()));
</method>
</class>
<stylesheet>
boxmodel { padding: 10 }
tooltip { content: "Traditional tooltip" }
</stylesheet>
<view layout="axis:y; spacing: 25" with="boxmodel">
<view layout="axis: x; spacing: 20">
<button id="locale" onclick="this.setAttribute('text', this.text == 'us' ? 'eu' : 'us')">us</button>
<text multiline="true" width="250">
Click on the eu/us button to change locale. Hover over the blue box to see a locale-dependent tooltip
</text>
</view>
<view layout="axis: x; spacing: 20">
<view width="75" height="75" bgcolor="blue" clickable="true">
<timetip />
<text fgcolor="white" valign="middle" align="center">Dynamic</text>
</view>
<view width="75" height="75" bgcolor="lime" clickable="true">
<tooltip />
<text fgcolor="white" valign="middle" align="center">Static</text>
</view>
</view>
</view>
</canvas>
</example>
<p>
The appearance of the tooltip is determined by the canvas.tooltipview element
</p>
</text>
</doc>
</class>
</library>
Cross References
Includes
Classes
- <class name="tooltip" extends="node">