Reputation: 75
I have a FocusPanel in which contains a Label. And then I add the DragStartHandler to FocusPanel like the code below:
focusPanel.addDomHandler(new DragStartHandler() {
@Override
public void onDragStart(DragStartEvent event)
{
focusPanel.getElement().getStyle().setBackgroundColor("yellow");
event.getDataTransfer().setDragImage(focusPanel.getElement(), 10, 10);
dragSourceIndex = getFocusPanelIndex(focusPanel);
}
}, DragStartEvent.getType());
I can drag this in Chrome, but cannot do this in IE and Firefox. Moreover, if I highlight the focuspanel's text first, then I can drag when it's highlighted.
Does anyone know what is wrong?
Thanks.
Upvotes: 1
Views: 161
Reputation: 75
I make a go-around by adding highlight on MouseDownEvent.
focusPanel.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event)
{
markText(focusPanel.getWidget().getElement());
}
});
The markText method is learn from here: Set selected text in GWT (in order to make copy paste easier)
This is a hacking but at least works. Now the issue is, the "drop" events are not happening in IE. I use IE 11.
Upvotes: 1