PDA

View Full Version : making set visible instead of deleting the node


mallesh
01-30-2004, 06:33 AM
Hi Antun,

<view id="removeV" datapath="clipdataset:/ClipArtImg" >
<text font="helv" x="18" y="320" height="15" clickable="true" fgcolor="red" >
<font size="12" ><b>Undo</b></font>

<method event="onclick">
this.datapath.deleteNode();
this.datapath.selectPrev();
</method>
</text>
</view>
In the above code i am able to delete the images (those which are from dataset).I don't want to delete the images by deleting the node but make it to set visible false so that i can use it in latter part of appln by making set visible true.So How do i do this?


Thanks
Mallesh.

antun
01-30-2004, 09:13 AM
I think I answered that here:

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=632#post2287

-Antun

mallesh
02-03-2004, 06:50 AM
Hi Antun,
in the below code

<view datapath="clipdataset:/ClipArtImg" >

<text font="helv" x="18" y="320" height="15" clickable="true" fgcolor="red" >
<font size="12" ><b>Undo</b></font>

<method event="onclick">
this.datapath.deleteNode();
yhis.datapath.selectPrev();
</method>
</text>
</view>

how can i use "set visible false" instead of deleting the node.In the previuos thead u told me to use selection manager class.But i don't want to use selection manager (becouse when i click on the UNDO button, the lattest image should disappear and so an and also when i click on the REDO button, the reverse should happen. )But these feature can't be implement using selection manager.


Thanks
Mallesh

antun
02-04-2004, 01:55 PM
I think it would be just:


<view datapath="clipdataset:/ClipArtImg" >

<text font="helv" x="18" y="320" height="15" clickable="true" fgcolor="red" >
<font size="12" ><b>Undo</b></font>

<method event="onclick">
this.setVisible( false );
yhis.datapath.selectPrev();
</method>
</text>
</view>


Does that not work?

-Antun

mallesh
02-05-2004, 06:09 AM
Hi Antun,

<method event="onclick">
this.setVisible( false );
yhis.datapath.selectPrev();
</method>

not working!
so any other alternative solution for the same?


Thanks
Mallesh.

antun
02-05-2004, 01:07 PM
I just tried this:


<canvas>
<dataset name="clipdataset">
<ClipArtImg />
</dataset>

<view datapath="clipdataset:/ClipArtImg" >

<text x="18" y="320" height="15" clickable="true" fgcolor="red" >
<font size="12" ><b>Undo</b></font>

<method event="onclick">
this.setVisible( false );
yhis.datapath.selectPrev();
</method>
</text>
</view>

</canvas>


... and it definitely does work. I'm not sure if you want to make the "Undo" button itself invisible however. If you want to act on some other view, you have to have a pointer to it.

You could say:


canvas.myview.setVisible( false );


... or if it's a replicated view, you have to talk to its replication manager that should be named:


var viewToHide = canvas.myReplMan.getCloneNumber(3);
viewToHide.setVisible( false );


-Antun

mallesh
02-06-2004, 05:34 AM
Hi Antun,

I tried to use getCloneNumber() method on class which create replicated views but no luck.
Actualy what i want to do is, when i click on the undo button, the lattest clone should disappear and then next one, and so on. And reverse should happen when i click on the redo button.

I am sending the code as attachment.

antun
02-06-2004, 11:34 AM
The code below works fine:


<canvas debug="true">
<dataset name="clipdataset"
src="clipartdb.xml"
autorequest="true"
type="http" />
<class name="clipartimage">
<method name="applyData"
args="d">
if (d == null) { return; }
setSource( d );
</method>
</class>
<class name="top"
extends="state">
<attribute name="xroffset"
value="$once{this.getMouse('x')}" />
<attribute name="initx"
value="$once{this.x}" />
<attribute name="initwidth"
value="$once{this.width}" />
<attribute name="width"
value="${this.initwidth+this.initx
-this.immediateParent.getMouse('x')+xroffset}" />
<attribute name="x"
value="${this.immediateParent.getMouse('x')
-this.xroffset}" />
<attribute name="yroffset"
value="$once{this.getMouse('y')}" />
<attribute name="inity"
value="$once{this.y}" />
<attribute name="initheight"
value="$once{this.height}" />
<attribute name="height"
value="${this.initheight+this.inity
-this.immediateParent.getMouse('y')+yroffset}" />
<attribute name="y"
value="${this.immediateParent.getMouse('y')
-this.yroffset}" />
</class>
<class name="clipartView">
<selectionmanager name="selector"
toggle="false" />
<clipItem name="cpitem"
x="${Math.round( Math.random() * 200 )}"
y="${Math.round( Math.random() * 200 )}"
datapath="clipdataset:/Clip/ClipArtImg"
width="90"
height="90"
clickable="true"
onclick="this.parent.selector.select(this);"
onmousedown="draggable.apply();"
onmouseup="draggable.remove();">
<resizestate name="rs" />
<top name="trrs" />
<dragstate name="draggable" />
<method name="setSelected"
args="amselected">
if ( amselected )
{

this.crb.setVisible(true);
this.crb2.setVisible(true);
this.bringToFront();

}
else
{

this.crb.setVisible(false);
this.crb2.setVisible(false);
}
</method>
<view name="crb"
align="right"
valign="bottom"
visible="false"
width="5"
height="5"
bgcolor="red"
onmousedown="parent.rs.apply();"
onmouseup="parent.rs.remove()" />
<view name="crb2"
align="left"
valign="top"
visible="false"
width="5"
height="5"
bgcolor="red"
onmousedown="parent.trrs.apply();"
onmouseup="parent.trrs.remove()" />
</clipItem>
<method event="onkeydown"
reference="LzKeys"
args="k">
if (k==46) {
var selectedNode = this.selector.selected[0];
Debug.write( "setVisible set to false" );

selectedNode.setVisible(false);//.deleteNode();
}
</method>
</class>
<class name="clipItem">
<clipartimage stretches="both"
width="${parent.width}"
height="${parent.height}"
datapath="ClipArt/text()" />
</class>
<clipartView width="200"
height="200"
name="myclipview" />
<button x="10"
y="200">Undo
<attribute name="cnum"
value="0" />
<method event="onclick">
var viewToHide = myclipview.selector.selected[0];
Debug.write( viewToHide );
canvas.lastNodeDeleted = viewToHide;
viewToHide.setVisible( false );
</method>
</button>
<button x="100"
y="200">Redo
<attribute name="cnum"
value="0" />
<method event="onclick">
var viewToShow = canvas.lastNodeDeleted;
viewToShow.setVisible( true );
</method></button>
</canvas>


I recorded the last deleted item in a global variable (canvas.lastNodeDeleted) and made that visible.


Actualy what i want to do is, when i click on the undo button, the lattest clone should disappear and then next one, and so on.


I see. Then you should record the clones as they get created in some kind of stack, and go through it when the undo button is clicked. That's very similar to what I did above with the global variable, only you would be using a global array to keep track.

-Antun

rsilvergun
09-15-2010, 08:31 PM
I needed to destroy() a bunch of dynamically created views based on their 'type' attribute. First I create the views:

new lz.view( this, {source: image, type: 'characterBox' } );

Then I just iterated through the subnodes array using for-loops, sticking anything I wanted to destroy into an array. I did this because calling destroy shifts the array index of everything:

<method name='destroyCharacterBoxes'>

<![CDATA[

var characterNodes = [];

var i=0;

for (i=0;i < this.subnodes.length;i++){ //Since I can't guarantee the index of my layout object for the characterbox, I push all the characterBox nodes onto an array so I can destroy them later.

if (this.subnodes[i].type == "characterBox"){ //skip the layout object

characterNodes.push(this.subnodes[i]);
Debug.debug ( this.subnodes[i].type );

}

}//END FOR LOOP

for (i=0; i < characterNodes.length; i++){

characterNodes[i].destroy();

}//END FOR LOOP

numNodes = this.subnodes.length;
var nodeLeft = this.subnodes[0].name;

Debug.debug("Number of nodes left " + numNodes + " :: " + nodeLeft);

]]>

</method>