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>
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>