Disable Left, Right, Top and Bot drop location

Hi,

i only want to drop something in the MIDDLE drop location and disable all others, so it can only be dropped on an item. Is it possible to disable all the other drop locations?

BTW i’m not in a table or tree. I have a HorizontalLayout which contains 4 labels and i want to drop something on those labels, but not inbetween.

Cheers

Samuel

It depents on the drop target. For selection components, such as Tree or Table, there is AbstractSelect.VerticalLocationIs accept criterion, which you can define in the getAcceptCriterion(), as
described in the book
.

For DragAndDropWrapper, there isn’t such criterion, to my knowledge. I don’t know what kind of situation you have, but perhaps you could do the same with a Table with some tweaking.

You can work around the problem by disabling the unwanted accept indicators
as described here
. That disables the indicators just visually, dropping on the locations is still allowed, but it might not be a problem for you if it’s just necessary to handle drops anywhere in the target.

You can completely ignore drops based on the drop location somewhat as follows:

    public void drop(DragAndDropEvent event) {
        WrapperTargetDetails target = (WrapperTargetDetails)
            event.getTargetDetails();

        // On which side of the target the item was dropped 
        VerticalDropLocation vlocation = target.getVerticalDropLocation();
        HorizontalDropLocation hlocation = target.getHorizontalDropLocation();
        
        if (vlocation == VerticalDropLocation.MIDDLE && hlocation == HorizontalDropLocation.CENTER)
            ... // Handle the drop here
        else
            // Could just return here or something

You could, of course, also use ServerSideCriterion, but it creates a lot of server requests.

Ah great, this will do it i guess:

layout.addStyleName(“no-vertical-drag-hints”);
layout.addStyleName(“no-horizontal-drag-hints”);

And then just handle the middle drops. Thanks for your help.