PDA

View Full Version : [GXT 1.2.3] Incorrect drop container



psionic1
15 Apr 2009, 11:31 PM
GXT 1.2.3
Hosted mode, IE6, FF3, Opera9.6

During working on sample from earlier bug (http://extjs.com/forum/showthread.php?t=64922), I encountered another.
When two DropTargets are close, but they are in different groups, following situation occurs:
object from group A is dragged over target with group A, then immediately dragged over second target (group B), and released there is placed on first target (with group A), instead of canceling D&D.

code:


public class GxtDemo implements EntryPoint {
public void onModuleLoad() {
LayoutContainer lc = new LayoutContainer();
lc.setLayout(new FitLayout());
lc.setLayoutOnChange(true);
lc.add(new ErrorDNDExample());
RootPanel.get().add(lc) ;
}
}

public class ErrorDNDExample extends LayoutContainer {
public ErrorDNDExample() {
HorizontalPanel hp = new HorizontalPanel();
hp.setSpacing(10);
VerticalPanel vp = new VerticalPanel();
for (int i = 1; i <= 16; i++) {
HorizontalPanel hp1 = new HorizontalPanel();
Label lb = new Label("Slot " + i);
hp1.add(lb);
final LayoutContainer lc = new LayoutContainer();
lc.setLayout(new FitLayout());
lc.setLayoutOnChange(true);
lc.setBorders(true);
lc.setSize(200, 20);
DropTarget target = new DropTarget(lc) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
Html html = (Html) event.data;
lc.add(html);
}
};
if (i>=10){
target.setGroup("test");
}
else{
target.setGroup("no_drag");
}
hp1.add(lc);
vp.add(hp1);
}
hp.add(vp);

final LayoutContainer clipboard = new LayoutContainer();
clipboard.setLayoutOnChange(true);
clipboard.setBorders(true);
clipboard.setSize(200, 16*20);
DropTarget targ = new DropTarget(clipboard) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
Html html = (Html) event.data;
clipboard.add(html);
}
};
targ.setGroup("test");
targ.setOverStyle("drag-ok");
for (int j =0; j<3; j++){
addSource(clipboard, j);
}
hp.add(clipboard);
add(hp);
}

private void addSource(LayoutContainer clipboard, int j){
final Html html = new Html("Card "+j );
html.setStyleAttribute("border", "1px solid red");
html.setStyleName("text");
DragSource source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.data = html;
event.status.update(El.fly(html.getElement()).cloneNode(true));
}
};
clipboard.add(html);
source.setGroup("test");
}
}


You can only put a card into slots 10-16. If you drag a card over 10th, then 9th, and release it on 9th, then card is dropped into 10th slot.
Tested on IE6, FF3, Opera9.6, and hosted mode

BTW: any change on the first bug?