PDA

View Full Version : Drag and Drop


emaender
01-02-2004, 01:43 PM
Hello!

I've studied the Amazon and Calendar sample applications, and I have a question regarding drag and drop functionality.

I'm working on an application where we will need to drag and drap components onto a design sheet. Picture a "drawing" application, where the user will be dragging a number of images onto a design canvas, then moving the images around. In addition, images may be dragged onto another image, and in this case they will need to be contained INSIDE that image. In other words, the image will now have a new parent, no longer the canvas, but the image it was dragged into.

I was able to create a simple example using datasets, where an image could be dragged into another, and a record would be added to a dataset therefore replicating the image within the parent image. However, we anticipate on the order of 100 images or more in our application. In that case, each image would need 100 different datasets all used to replicate images that may be dragged in, etc. I'm hoping there may be a more elegant approach to this problem.

The core of my question is, is there a way to "reassign" an object (say, for example, a view) to another parent? I've figured out that this.deleteNode() gives me the capability to remove the image from wherever I'm pulling it, but I haven't figured out a way to make it a child of another object, outside of the dataset approach. Any ideas?

Thanks in advance for your help with this!

antun
01-05-2004, 02:15 PM
Hi there

I'm glad you decided to talk about your design strategy up front - that's always good!


However, we anticipate on the order of 100 images or more in our application.


I haven't seen your code, but I can't think of any reason why you have to create a dataset for every image. You could just have one dataset, with a single root node, and have each top-level image as a child of that. For example:


<dataset name="mydataset">
<allimages>
<image graphic="img1.jpg" xpos="30" ypos="100" />
<image graphic="img3.jpg" xpos="20" ypos="65" />
<image graphic="img1.jpg" xpos="33" ypos="74" />
<image graphic="img2.jpg" xpos="125" ypos="21" />
</allimages>
</dataset>


If you need a hand with this model, feel free to post some code and I'll see what I can do to help.

The core of my question is, is there a way to "reassign" an object

There isn't as far as I know, but the replication model you suggested is the most elegant I can think of. Like you said you could also delete the node and then create a new one. You could write a function or method to do that, that took a pointer to the node to copy and a pointer to the adoptive parent as arguments, where the guts of the method took care of setting the relevant attributes of the child node. However I can see this becoming cumbersome if a node has many subviews, since you would have to write a recursive function that copied them over.

-Antun

antun
01-05-2004, 04:07 PM
Just thought I'd let you know that that I filed a feature request for the ability to move a view from one parent to another.

-Antun

emaender
01-07-2004, 02:07 PM
Thanks Antun. Datasets are great, but really the capability to "reparent" views would be very powerful.

We are building a workaround method, and I assure you, it is VERY clumsy.

Thanks again for your help and input!

mericson
06-28-2005, 07:43 PM
emaender,

I've been curious if you were succesful in building your application. Did the work-around help you? Did reparent ever get added to Laszlo?

I've been thinking of another idea for drag-drop... clone on drag.

Perhaps rather than 'reparenting' a view it might be possible to 'clone on drag' and have a view without a parent, that is assigned to a parent upon drop.

emaender
06-29-2005, 06:59 AM
We actually switched from Laszlo to MM Flex early this spring. The drag and drop workaround we were playing with never came to fruition.

mericson
06-29-2005, 08:12 AM
Did you find that Flex has good drag/drop capabilities?

emaender
06-29-2005, 10:43 AM
Flex does have an extensive drag/drop API. We have used it quite a bit. The drawback to Flex is it's price. It is truly intended for enterprise-level applications.

lwz7512
07-05-2005, 01:57 AM
currently using position judgement of view is rather complex, so, expecting the future version of laszlo has a powerful and convenient method to drag and drop!

mericson
07-05-2005, 05:47 AM
I'm so used to open-source projects with extreme transparency. Does Laszlo have a roadmap of milestones and releases?

A great example is the Eclipse projects. It really helps in planning to know what to expect when!

d~l
07-05-2005, 07:48 AM
roadmap (http://www.openlaszlo.org/development/roadmap/)

mayankk
06-07-2007, 07:48 AM
roadmap (http://www.openlaszlo.org/development/roadmap/)
The roadmap has been moved to http://wiki.openlaszlo.org/Platform_Roadmap