0

Problem with copy and paste using drag n drop

asked 2007-09-24 11:41:23 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4533942

By: bobobobo

Hi!

I just realized that if you have a textbox and copy and paste data to it by dragging and dropping text to it, it will not trigger onchange or onchanging, therefore my databinding wont work. Is there any easy way around this?

/Bobo

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2007-09-26 02:46:17 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4537591

By: jebberwocky

Dear Bobo

This might be caused by the target textbox is not focused. For example: There are textbox A and B, you drag and drop value from A to B, the value is copied, but focus is still on A not B. As a result, the onchang and onchanging won't be trigged on B. It seems a natural tendency of input html element. Hope this will help.



link publish delete flag offensive edit

answered 2010-02-17 10:06:37 +0800

dhamu gravatar image dhamu
165 1 6

Could someone provide an example of the copy and paste via drag and drop? I am envisioning that on drag a copy of the dragged object would be created, but it should be a seamless and clean action and then the copy would be dropped on the target. If the target rejects the copy or the user cancels the drag, then the copy would need to be destroyed.

link publish delete flag offensive edit

answered 2010-02-23 00:25:17 +0800

PeterKuo gravatar image PeterKuo
481 2

@dhamu
Seems you answered it by yourself in other thread.
Drag and Drop and organizing dropped items
http://www.zkoss.org/forum/listComment/11368

Would you like to share the code?

link publish delete flag offensive edit

answered 2010-02-23 10:25:51 +0800

dhamu gravatar image dhamu
165 1 6

I can provide code if necessary. The way that I solve the problem is to create a clone of the object that is being dragged and depending on the type of object being dragged, you need to execute the setParent() to associate the clone with the source parent and the original object with the destination parent. I'm not sure that my code would be helpful to the original poster. On the other hand, if the original poster were to provide a bare-bones example of what he is trying to do, I will response with my suggestions.

link publish delete flag offensive edit

answered 2010-02-23 11:36:46 +0800

dhamu gravatar image dhamu
165 1 6

I forgot that I had already created a minimal code example for this.

<zk>
<hbox>
<zscript>
org.zkoss.zk.ui.AbstractComponent;

void moveFromSourcetoTarget(AbstractComponent comp, AbstractComponent dragged) {
if (dragged.getParent().getId().equals("source_list")) {
AbstractComponent clone = dragged.clone();
dragged.setId("orig_" + dragged.getId());
dragged.getParent().insertBefore(clone, dragged);
}
dragged.setParent(comp);
}
</zscript>
<listbox id="source_list" width="200px" rows="5">
<listhead>
<listheader label="Source Data" sort="auto"/>
</listhead>
<listitem draggable="A" id="field_1" label="field_1"/>
<listitem draggable="A" id="field_2" label="field_2"/>
<listitem draggable="A" id="field_3" label="field_3"/>
<listitem draggable="A" id="field_4" label="field_4"/>
<listitem draggable="A" id="field_5" label="field_5"/>
<listitem draggable="A" id="field_6" label="field_6"/>
<listitem draggable="A" id="field_7" label="field_7"/>
<listitem draggable="A" id="field_8" label="field_8"/>
<listitem draggable="A" id="field_9" label="field_9"/>
</listbox>

<listbox droppable="A" id="working_list" width="200px" rows="5" onDrop="moveFromSourcetoTarget(self, event.dragged)">
<listhead>
<listheader label="Working Data" sort="auto"/>
</listhead>
</listbox>

<listbox droppable="A" id="trash_list" width="200px" rows="1" onDrop="moveFromSourcetoTarget(self, event.dragged)">
<listhead>
<listheader label="Trash" sort="auto"/>
</listhead>
</listbox>

</hbox>
</zk>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-09-24 11:41:23 +0800

Seen: 410 times

Last updated: Feb 23 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More