PDA

View Full Version : inputext new line hold problem


Nishizaka
08-09-2005, 02:37 AM
Hi All.
all new line deleted problem pattern is inputtext id a is key type after
[a -> Insert + 'AAA'] button as text insert.
Someone, please teach the method of settlement.

<?xml version="1.0" encoding="UTF-8"?>
<canvas width="100%" height="100%" debug="true">
<debug x="300" y="10" height="600"/>

<dataset name="DB">
<text>
<![CDATA[
Partly Cloudly
Partly Cloudly
Partly Cloudly
Partly Cloudly
Partly Cloudly
]]>
</text>
</dataset>

<class name="myinputtext" extends="inputtext">
<attribute name="xpos" value="0" type="number"/>
<attribute name="sizepos" value="0" type="number"/>
<method name="dothis">
<![CDATA[
Debug.write("SIZE: " + getSelectionSize());
Debug.write("POSITION: " + getSelectionPosition());

var a = getSelectionSize();
var b = getSelectionPosition();

setAttribute('xpos', a);
setAttribute('sizepos', b);
]]>
</method>

<method name="Insert" args="str">
<![CDATA[
var s = escapeText();
var p = sizepos;

if (p > 0)
{
var s1 = s.substring(0,sizepos);
var s2 = s.substring(sizepos+xpos);

Debug.write("org: [" + getText() + "]");
Debug.write("s : [" + s + "]");
Debug.write("s1 : [" + s1 + "]");
Debug.write("s2 : [" + s2 + "]");

s = s1 + str + s2;
setText(s);
setSelection(sizepos+xpos+str.length);
}
else
{
Debug.write("s: " + s);

s = str + s;
setText(s);
setSelection(str.length);
}
dothis();
]]>
</method>

</class>

<simplelayout />

<view width="250" height="150" bgcolor="0xFFFFC8" datapath="DB:/*">
<simplelayout axis="x" spacing="5" />
<myinputtext id="a" bgcolor="0x80ff80" multiline="true" selectable="true"
width="${parent.width*0.95}" height="${parent.height*0.95}"
valign="middle"
align="center"
text="$path{'text()'}"
/>

</view>
<view width="250" height="150" bgcolor="0xFFFFC8">
<simplelayout axis="x" spacing="5" />
<myinputtext id="b" bgcolor="0xffa2ff" multiline="true" selectable="true"
width="${parent.width*0.95}" height="${parent.height*0.95}"
valign="middle"
align="center"
/>
</view>

<button text="DB -> b (serialize)" onclick="b.setText(DB.serialize())" />
<button text="DB -> a" onclick="a.setText(a.datapath.getNodeText())" />
<button text="DB -> b" onclick="b.setText(a.datapath.getNodeText())" />
<button text="a -> b" onclick="b.setText(a.getText())" />
<button text="b -> a" onclick="a.setText(b.getText())" />
<button text="a -> DB" onclick="a.datapath.setNodeText(a.escapeText())" />
<button text="a -> Insert + 'AAA'" onmouseover="a.dothis()" onclick='a.Insert("AAA")' />
<button text="a -> Insert + 'BBB'" onmouseover="a.dothis()" onclick='a.Insert("BBB")' />

</canvas>

hqm
08-09-2005, 05:04 AM
There is a known bug with newlines being stripped from inputtext when you call getText().

There is a fix in the nightly build, have you tried downloading and running the LPS server from the openlaszlo nightly build pages?

http://www.openlaszlo.org/download/

Nishizaka
08-09-2005, 08:39 PM
Thanks.
3.0.1d1 is OK!

wjl
10-13-2005, 12:03 AM
Hi. According to hqm, the fix is in nightly build, and according to Nishizaka, it works for 3.0.1d1. I am using 3.0.2 (newer than 3.0.1d1???) but my getText still strips the new lines. I have posted this at

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=4091&highlight=multiline

Why the fix is not applied in 3.0.2?

Thanks

Nishizaka
10-13-2005, 12:17 AM
Hi.

3.0.2 is The problem is not corrected.
try 3.1cr3 or Nightly build.

wjl
10-13-2005, 01:29 AM
Thanks Nishizaka! It works on the latest nightly build as well.

However, our company's project is now running 3.0.2, and I do not want to take the risk of migrating entirely to this nightly build version. I just need the fix for this problem. Can anyone teach me how to extract just this fix from the nightly build, and combine it into my 3.0.2?

Much appreciated. Thanks!

hqm
10-13-2005, 03:39 AM
It would still be somewhat risky to try to port just the input text handling code change, but you could do it as a patch for a given application with no risk.

You can grab code from WEB-INF/lps/lfc/views/LzText6.as and LzInput6.as, and put them in <script> blocks at the start of your app.

I would need to look through the version control logs to figure out which changeset fixed this bug.
I don't have time to do that at the moment, but
I would suggest looking at the setText and getText methods on LzText and lzInputText