PDA

View Full Version : [FIXED] [2.0 M1] Bug in dragSource.disable()



Rvanlaak
4 May 2009, 1:28 AM
When using the DnD functionality, I want to disable the dragSource when an event happens. I've got it working, but it seems GXT doesn't really disable the dragging, but only hides the content. It is still possible to drag and it leaves a artifact at the right bottom of the mouse cursor (as shown on screenshot)

Code sample (without get/setters and imports) :




public class QueueCurrent extends LayoutContainer {

private Html html;
private String callerNumber;
private String sourceChannel;
private Button redirectButton;
private Button notesButton;
private NoteDetailsWindow noteWindow = new NoteDetailsWindow();
private DragSource source;

private StaticServiceAsync asterSvc = GWT.create(StaticService.class);

public QueueCurrent() {

setLayoutOnChange(true);
setBorders(true);
setSize(200, 50);

html = new Html();
add(html, new FlowData(3));

source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.setData(html);
event.getStatus().update(
El.fly(html.getElement()).cloneNode(true));
}

@Override
protected void onDragDrop(DNDEvent event) {

super.onDragDrop(event);

System.out.println("DragSource: " + event.getDragSource());
System.out.println("DropTarget: " + event.getDropTarget());

}
};
// group is optional
source.setGroup("dnd-call");

// Set initial state
unsetCallData();
}

/**
* Set the source channel of the DnD box, needed for redirecting
*/
public void setCallData(String name, String sourceChannel, String callerNumber) {
html.setHtml(name);
html.setStyleName("queueCurrent-active");
html.setToolTip("Kanaal: " + sourceChannel);
setSourceChannel(sourceChannel);
setCallerNumber(callerNumber);
redirectButton.setEnabled(true);
notesButton.setEnabled(true);
source.enable();
}

public void unsetCallData( ) {
html.setHtml("---");
html.setStyleName("queueCurrent-inactive");
html.hideToolTip();
setSourceChannel(null);
setCallerNumber(null);
redirectButton.setEnabled(false);
notesButton.setEnabled(false);
source.disable();
}

}

Rvanlaak
5 May 2009, 2:42 AM
As i've compiled the application to Firefox, it seems that FF doesn't show above artifact under the cursor.

If I open the same compiled site in IE7, the dashed artifact does show up. It isn't a Hosted-Mode only bug...

sven
5 May 2009, 2:44 AM
Yes i confirmed that and have a fix ready.

Rvanlaak
5 May 2009, 7:28 AM
Looks like the Hosted mode does use IE to render things.. :P

Rvanlaak
7 May 2009, 1:33 AM
Is it also possible to disable the status fly ghost item? When the DragSource is disabled, the ghost still stays active. I can't find a way to disable the ghost.

Besides that,, how can I drag DataListItems? The example explorer tells about List to List dnd, but I want to drop a list item at top of a other target (button). The ListViewDragSource is able to drag multiple items, but I only want to drag one item.

Rvanlaak
7 May 2009, 1:37 AM
Actually, it looks like the List selection mode is blocking the DnD event. Is it possible to disable a list from selection?

sven
13 May 2009, 8:20 AM
Fixed in SVN.

Rvanlaak
26 May 2009, 1:45 AM
The bug is solved in the M2 build. Now a selection will be made. Is it possible to override this select action? The entire viewport is filled with blue because of the selection.

Rvanlaak
27 May 2009, 2:14 AM
Actually, it looks like the List selection mode is blocking the DnD event. Is it possible to disable a list from selection?

I can't figure out how to make the items in a datalist draggable, is this fixed in the M2 build or am i doing something wrong?





public class QueueItem extends DataListItem {

............

public QueueItem(String callerIdName, String phoneNumber, String uniqueId,
String channel, String queueName) {

.......


source = new DragSource( this ) {

@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.setData( getChannel() );
event.getStatus().update( getCallerIdName() );

System.out.println("DragStart");
}

};
// group is optional
source.setGroup("dnd-call");

}
}


Playing with some of the DataList properties doesn't work... :(

Rvanlaak
28 May 2009, 4:34 AM
Anybody who has got the Dragging working withing lists?

Rvanlaak
28 May 2009, 4:37 AM
Anybody who has got the Dragging working withing lists?

I've found the sollution. It is the list wich is draggable, not the items in it!



DragSource source = new DragSource( this ) {

@Override
protected void onDragStart(DNDEvent event) {

QueueItem item = (QueueItem)getSelectedItem();

// by default drag is allowed
event.setData( item.getChannel() );
event.getStatus().update( item.getCallerIdName() );

System.out.println("DragStart");
}

};