<<openLaszloInstall>>\lps\components\incubator
) has several useful components and features for developing rich web applications. These include form validators, the rich text editor (Flash runtime only, not DHTML), and tool tips (the subject of this blog entry).The concept of a tool tip is familiar to just about anyone who has written an HMI in recent years. In HTML, a tooltip can be easily provided using the title attribute and it can be programmatically altered using JavaScript. Similarly, OpenLaszlo allows for static and dynamic setting of tooltips and OpenLaszlo can generally be compiled into JavaScript/DHTML or Flash runtime. In this blog entry, I'll demonstrate how simple it is to add a tool tip to an OpenLaszlo visual component.
This blog entry's example of applying an OpenLaszlo tooltip is trivial and is similar to those shown in the example in the OpenLaszlo blog entry Laszlo Mail Tooltip Contributed to OpenLaszlo and in the blog entry OpenLaszlo: Dynamic Tooltip Text. Here is a full example of OpenLaszlo code with a simple tooltip included.
<canvas title="Very Simple OpenLaszlo ToolTip Example">
<include href="incubator/tooltip/tooltip.lzx" />
<simplelayout axis="y" spacing="10" />
<inputtext id="toolTipInfo" text="Click Button">
<handler name="ontext">
mainButtonToolTip.setAttribute("text", this.getText());
</handler>
</inputtext>
<button id="mainButton" text="Click Me!">
<tooltip id="mainButtonToolTip" text="${toolTipInfo.text}" />
</button>
<button id="secondaryButton" text="No, Click Me!">
<tooltip>This is the secondary button.</tooltip>
</button>
</canvas>
The above source code will not compile with the lzc compiler if the include statement is not specified. This is shown in the next screen snapshot with the message "Unknown tag: tooltip".
With the include line
<include href="incubator/tooltip/tooltip.lzx" />
included, the source code above does compile correctly.The next series of screen snapshots show the tooltips used in the code above in action. The first two screen snapshots show the tool tips that are provided initially for each button and the third screen snapshot demonstrates the changed tool tip for the main button based on the text entered in the input text field.
All three screen snapshots above show the OpenLaszlo tooltip in an SWF8 runtime (now the default runtime in OpenLaszlo 4.1). Of course, OpenLaszlo's support for a DHTML runtime is a compelling feature for many developers. The next single screen snapshot shows the application running in DHTML. The image was captured after the
inputtext
field was changed to contain the contents "Dustin!".With the OpenLaszlo
tooltip
, it is possible to go back to the OpenLaszlo RSS Reader example and add tool tips to that reader. The next screen snapshot shows how this looks when one of the newly added tool tips is displayed.The OpenLaszlo tool tips are highly useful in providing additional detail to users. Fortunately, they are easy to add as well.
No comments:
Post a Comment