-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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.
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.
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.
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>
Asked: 2007-09-24 11:41:23 +0800
Seen: 410 times
Last updated: Feb 23 '10