Take the 2-minute tour ×

I am just trying to integrate textarea in dhtml environment. I am able to see the text area But i cannot type anything in the text area. Attached is a code snippet.

<canvas debug="true">
 <attribute name="htmlsnippet" type="string" value="" />

    <handler name="oninit" args="e">
        canvas.htmlsnippet = '<textarea id="textArea" rows="8" cols="50"></textarea>';

    <simplelayout axis="y" spacing="30" />

    <text id="textcont" width="530" height="350" bgcolor="#cccccc" />

    <button text="modify text" onclick="textcont.sprite.setText(canvas.htmlsnippet)" />
share|improve this question
What do you expect to happen? Do you want to dynamically create a new textarea, or do you want that text to appear as the text content in the textfield? –  raju-bitter Oct 29 '12 at 14:43
@RajuBitter: I have updated the question. I am able to see the text area but i am not able to type anything in the text area. –  karthick Oct 29 '12 at 15:40
add comment

1 Answer

up vote 2 down vote accepted

While it's possible to generate an HTML element at runtime and add that to the display object of a view, the OpenLaszlo kernel will process all the mouse and keydown events and not pass them on to the textarea you created.

The <inputtext> component in OpenLaszlo instantiates an internal <textarea>. Compile the following OpenLaszlo DHTML app:

<canvas debug="true">

  <inputtext id="iText" multiline="true" width="100" resize="true" bgcolor="red">
    <handler name="oninit"><![CDATA[
        this.setAttribute('text', 'Just\na\ntest!');


Now inspect the text object by entering this expression into the browser JavaScript console:


and you will see something like:

<textarea class="lzswfinputtextmultiline" name="" style="color: rgb(0, 0, 0); width: 96px; height: 40px; pointer-events: auto;">

Depending on the browser the style values could be different.

Unfortunately OpenLaszlo doesn't offer an API to add your custom textarea to the application without handling the keydown, focus and mouse events for the textarea yourself. That's effectively what the combination of LFC/kernel classes (LzText.lzs, LzInputText.lzs, LzTextSprite.js, LzInputTextSprite.js) do: They replicate the SWF text class behavior for DHTML - since OpenLaszlo had the SWF runtime before the DHTML runtime.

That's less than optimal for HTML5, and probably one of the greatest weaknesses of the OpenLaszlo platform. Therefore it's better to no add your own <textarea> to a DHTML runtime app - unless you put that into an iFrame/separate HTML page.

share|improve this answer
add comment

Your Answer


