Open Bebbolus opened 4 years ago
@Bebbolus can you add a snippet of how you're creating the drag source?
Also, regarding
N.B. is the same if you change it.dropEffect with dropTarget.dropEffect
I would assume that dropTarget.dropEffect
contains the selected DropEffect of the DropTarget. If you set a specific DropEffect to the DropTarget, it should only accept DropEffects of that type. Otherwise, it makes sense that the DropTarget's effect is always null.
Hi Olli,
the following code is my dragSource, I've also tryed setting dragSource.effectAllowed = EffectAllowed.MOVE
but nothing changed:
val otherBox = VerticalLayout()
val dragSource = DragSource.configure(otherBox)
dragSource.dragData = "this is my data"
dragSource.isDraggable = true
dragSource.addDragStartListener {
otherBox .addClassNames("dragged")
}
dragSource.addDragEndListener {
otherBox .removeClassNames("dragged")
}
the test I've done is simply dragging the box in the other box. I can do everything but mantaining the ctrl key pressed, alt key pressed and so on there is always null in the drop effect
Here is a Java example to reproduce the bug:
TextField dragSource = new TextField();
DragSource.create(dragSource);
VerticalLayout dropTarget = new VerticalLayout();
dropTarget.getStyle().set("background-color", "yellow");
DropTarget.create(dropTarget).addDropListener(event -> {
Notification.show("" + ((DropEvent) event).getDropEffect());
});
add(dragSource, dropTarget);
According to the document Making Any Component Draggable:
The DragEndEvent reports the dropEffect for the drop event. The value will be determined in priority order by:
The desired action dropEffect set by the drop target
The effectAllowed set to the drag source
The modifier keys the user had pressed and hold when dropping
For example, when I press option and hold the option key when dropping, the dropEffect
is still null.
So this is still open? I just noticed the same issue on Vaadin 24.1.12. I need this information to make a difference between COPY and MOVE to determine if I should remove the dragged Component from its parent and add it to the new location or just create a new instance at the new location. Does someone know any workarounds for this issue?
Description of the bug attaching DragAndDrop to a component (actually a VerticalLayout) I don't receive the drop effect it return always null
Refer to forum thread https://vaadin.com/forum/thread/18076254/18076255
Expected behavior return Enum DropEffect i.e. DropEffect.COPY
Actual behavior return always null
Minimal reproducible example
N.B. is the same if you change
it.dropEffec
withdropTarget.dropEffect
Stack: Vaadin Kotlin Spring Boot Maven IDE: IntelliJ