PDA

View Full Version : Using the LPS-1.0.2 windowtext component


javanaut
10-29-2003, 01:02 PM
What I want to do is quite simple. Given a Redmond windowtext component I want to clear the initial value of the text in the text field. Here's a code snippet which does not work:

<canvas debug="true">
<method name="showText">
debug.write('Got a click or something');
var myText = ourFld.getText();
debug.write(myText);
ourFld.setText("");
</method>
<windowtext id="input" name="ourFld" x="100" y="60" text="Hello" width="200" clickable="true" onclick="canvas.showText()">
</windowtext>
</canvas>

I have also tried using:
a) onclick="this.clearText()" since WEB-INF\lps\components\redmond\redmondinputtext.lzx shows that there is such a method;
b) onclick="this.setText('')"
c) placing the method "inline" with the windowtext component and using onclick="this.showText()"

I can't think of any other way of doing it. Am I doing something fundamentally wrong? Am I trapping for the wrong event? It must be obvious. Thanks in advance for your help.

antun
10-29-2003, 02:20 PM
First, a quick fix that will get you rolling:


<canvas debug="true">
<method name="showText">
debug.write('Got a click or something');
var myText = ourFld.getText();
debug.write(myText);
ourFld.setText("");
</method>

<windowtext id="input" name="ourFld" x="100" y="60"
text="Hello" width="200" clickable="true"
onfocus="canvas.showText()">
</windowtext>
</canvas>


Second, why wasn't it working with the onclick event handler?

The onclick event wasn't getting sent when you clicked on the windowtext, because you were clicking on the inputtext field inside the windowtext component, which has its own onclick behavior defined (it selects the text field for editing). I think that's the cause of it all - I did a quick test with the raw inputtext tag:


<canvas debug="true">

<inputtext id="input" name="ourFld" x="100" y="60"
text="Hello" width="200">
<method event="onclick">
debug.write( 'clicked' );
</method>
</inputtext>

</canvas>


... which didn't send a click. If you made it clickable (clickable="true"), it DID send the click, but it didn't allow you to type.

-Antun